+1  A: 

The article you linked to at MSDN says:

If no error occurs, connect returns zero. Otherwise, it returns SOCKET_ERROR,
and a specific error code can be retrieved by calling WSAGetLastError.

If I understand your question correctly, you want to know if "connect() did not succeed, and if that is the case, why it did not succeed". So, just check if connect() returns SOCKET_ERROR and then check the error code by calling WSAGetLastError.

Naaff
You mean I should call connect() again after select() tells me it's writable?
Patrick Daryll Glandien
No. Call connect() only once. If connect() fails, select() will set the socket in the exceptfds set, if you specify one when calling select(). getsockopt() will then retrieve the error code from the socket. Don't use WSAGetLastError(), as that will report whether select() itself failed.
Remy Lebeau - TeamB
+1  A: 
Nikolai N Fetissov