diff options
author | Chris Wilson <chris+github@qwirx.com> | 2007-10-17 12:52:47 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2007-10-17 12:52:47 +0000 |
commit | d4f5a3d2818414041fec547211f85ac83dd4adb7 (patch) | |
tree | 0bacc1ad2666e65dddf6b519e66c9368bd743849 /lib | |
parent | ff0a6528146d059b78cf5a34f087dc373bd81759 (diff) |
Report more useful error messages on connect() failure on Windows.
(merges [1851])
Diffstat (limited to 'lib')
-rw-r--r-- | lib/server/SocketStream.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/server/SocketStream.cpp b/lib/server/SocketStream.cpp index ebc57041..88bf386a 100644 --- a/lib/server/SocketStream.cpp +++ b/lib/server/SocketStream.cpp @@ -161,17 +161,26 @@ void SocketStream::Open(int Type, const char *Name, int Port) { // Dispose of the socket #ifdef WIN32 + DWORD err = WSAGetLastError(); ::closesocket(mSocketHandle); #else + int err = errno; ::close(mSocketHandle); #endif + BOX_ERROR("Failed to connect to socket (type " << Type << ", name " << Name << ", port " << Port << "): " << - "error " << errno << " (" << strerror(errno) << - ")"); + #ifdef WIN32 + GetErrorMessage(err) + #else + strerror(err) << " (" << err << ")" + #endif + ); + mSocketHandle = INVALID_SOCKET_VALUE; THROW_EXCEPTION(ConnectionException, Conn_SocketConnectError) } + ResetCounters(); } |