Working implementation of the socket server used by the client