According to MSDN you have to create a non-blocking socket like this:
unsigned nonblocking = 1;
ioctlsocket(s, FIONBIO, &nonblocking);
and use it in the write-fdset for select() after that. To check if the connection was successful, you have to see if the socket is writeable. However, the MSDN-article does not describe how to check for errors.
How can I see if connect() did not succeed, and if that is the case, why it did not succeed?
You check socket error with
getsockopt(). Here’s a snippet from Stevens (granted it’s Unix, but winsock should have something similar):Now
errorgives you the error number, if any.