Fixing socket communication between client and server