Added socket error handling
TODO: implementation for newConnection.
Perhaps we need more consideration in client backend