implement the socket communication