fixed socket error handling on the client and added minimal socket error handling on the server