This is wrong solution. Win32 regulary returns WSAENOTCONN when connection is in progress.
I guess the real problem is that we are here simulating blocking sockets using non-blocking behaviour. Win32 seems to give up connect in blocking mode after 21 seconds. So the correct solution is perhaps to simulate this special timeout as well - done, please check.
(You can also decrease the timeout using Timeout).