Corinna, after our long discussion about interruptible connects i did some checks with nonblocking connects.
While the opengroup spec is quite clear (and this time Linux behaves the same) that the first connect should return EINPROGRESS and following connects EALREADY cygwin returns always EINPROGRESS. Attached patch fix this to return EALREADY on the second and all following connects. As a side effect this will change interrupted blocking connects to return EALREADY too (and not block again) as we have discussed before. I think that this more opengroup alike. Thomas 2003-06-06 Thomas Pfaff <[EMAIL PROTECTED]> * fhandler_socket.cc (fhandler_socket::connect): Change error handling for nonblocking connects to return EALREADY when connect is called more than once for the same socket.
--- fhandler_socket.cc.org 2003-06-06 10:34:29.000000000 +0200 +++ fhandler_socket.cc 2003-06-06 10:45:00.000000000 +0200 @@ -502,6 +502,7 @@ fhandler_socket::connect (const struct s BOOL in_progress = FALSE; sockaddr_in sin; int secret [4]; + DWORD err; if (!get_inet_addr (name, namelen, &sin, &namelen, secret)) return -1; @@ -514,12 +515,12 @@ fhandler_socket::connect (const struct s when called on a non-blocking socket. */ if (is_nonblocking () || is_connect_pending ()) { - DWORD err = WSAGetLastError (); + err = WSAGetLastError (); if (err == WSAEWOULDBLOCK || err == WSAEALREADY) - { - WSASetLastError (WSAEINPROGRESS); - in_progress = TRUE; - } + in_progress = TRUE; + + if (err == WSAEWOULDBLOCK) + WSASetLastError (WSAEINPROGRESS); else if (err == WSAEINVAL) WSASetLastError (WSAEISCONN); } @@ -556,7 +557,8 @@ fhandler_socket::connect (const struct s } } - if (WSAGetLastError () == WSAEINPROGRESS) + err = WSAGetLastError (); + if (err == WSAEINPROGRESS || err == WSAEALREADY) set_connect_state (CONNECT_PENDING); else set_connect_state (CONNECTED);