improved socket
updated global logging write function and socket implementation