wish help you to fix your issue The answer ended up being that nearly any system calls can clear Win32's "LastError()" errors... In my case, throwing an exception meant formatting and logging a message, which caused the error to be clear... And even though I was calling WSAGetLastError() immediately in my catch(...) it was already too late...
will be helpful for those in need The problem is your implementation of operator const char*(). Once that function returns, your stringstream object is no longer valid because it is no longer in scope.
around this issue Socket error codes start at 10000. 64 is not a documented socket error code that WSAGetLastError() can return. However, Windows error code 64 is ERROR_NETNAME_DELETED ("The specified network name is no longer available.").
this will help You are initializing the Socket member to the wrong value in the Winsock constructor - NULL instead of INVALID_SOCKET. They are not the same value. You are calling WSAAsyncSelect() regardless of whether socket() succeeds or fails. You are displaying error messages if things fail, but you are not stopping your code when they do fail. You need to clean up your error handling.
fixed the issue. Will look into that further Missed some context in the problem description. The socket was bound to an I/O completion port. The function call failed but result of ConnectEx was received through GetQueuedCompletionStatus in a worker thread. EDIT: I should have called WSAGetLastError() instead.