diff options
author | attilamolnar <attilamolnar@hush.com> | 2012-09-13 01:53:42 +0200 |
---|---|---|
committer | attilamolnar <attilamolnar@hush.com> | 2012-09-13 14:16:11 +0200 |
commit | e67dff32ced4be1ec0a8539c29fd44bee9077923 (patch) | |
tree | c9d5249878228fc3007a9c58f386ac314961bc19 /src/socketengine.cpp | |
parent | 2ef3dffd4781082988ffaaab3d786733b1b96a18 (diff) |
Set errno to EINPROGRESS on Windows when the connect() call does not complete immediately, to simulate unix behavior
This makes code that checks errno to determine whether connect() has succeeded or not work properly on Windows
Fixes #298 reported by @butaman
Diffstat (limited to 'src/socketengine.cpp')
-rw-r--r-- | src/socketengine.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/socketengine.cpp b/src/socketengine.cpp index 72075dd49..ccaa71aed 100644 --- a/src/socketengine.cpp +++ b/src/socketengine.cpp @@ -208,7 +208,12 @@ int SocketEngine::SendTo(EventHandler* fd, const void *buf, size_t len, int flag int SocketEngine::Connect(EventHandler* fd, const sockaddr *serv_addr, socklen_t addrlen) { - return connect(fd->GetFd(), serv_addr, addrlen); + int ret = connect(fd->GetFd(), serv_addr, addrlen); +#ifdef WINDOWS + if ((ret == SOCKET_ERROR) && (WSAGetLastError() == WSAEWOULDBLOCK)) + errno = EINPROGRESS; +#endif + return ret; } int SocketEngine::Shutdown(EventHandler* fd, int how) |