fix socket-connection logick for the client