diff options
Diffstat (limited to 'winsup/cygwin/net.cc')
-rw-r--r-- | winsup/cygwin/net.cc | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc index 7077220bc..1715b16cb 100644 --- a/winsup/cygwin/net.cc +++ b/winsup/cygwin/net.cc @@ -868,13 +868,18 @@ cygwin_connect (int fd, if (res) { /* Special handling for connect to return the correct error code - when called to early on a non-blocking socket. */ - if (WSAGetLastError () == WSAEWOULDBLOCK) + when called on a non-blocking socket. */ + if (sock->is_nonblocking ()) { - WSASetLastError (WSAEINPROGRESS); - in_progress = TRUE; + DWORD err = WSAGetLastError (); + if (err == WSAEWOULDBLOCK || err == WSAEALREADY) + { + WSASetLastError (WSAEINPROGRESS); + in_progress = TRUE; + } + else if (err == WSAEINVAL) + WSASetLastError (WSAEISCONN); } - set_winsock_errno (); } if (sock->get_addr_family () == AF_UNIX) |