Wrap exceptions of connecting to socket.