added exception handling for client socket writing