Added checks in server and client to prevent data loss over sockets.