Working version of socket server