Every time I call connect() on a host that isn't alive it takes like 30 seconds to complete... I want to minimize this time by specifying my own "timeout", so say... I want a timeout of 5 seconds, if connect() cannot find the host in 5 seconds then the function returns. I'm looking on MSDN and all I can see it say is this:

Code:
With a nonblocking socket, the connection attempt cannot be completed immediately. In this case, connect will return 
SOCKET_ERROR, and WSAGetLastError will return WSAEWOULDBLOCK. In this case, there are three possible scenarios:

* Use the select function to determine the completion of the connection request by checking to see if the socket is writeable.
But the only problem is that MSDN doesn't mention HOW to make the socket or connect() nonblocking.

So I'm just wondering how I can do this, I'm going to be using a function Check_Host() and I'm guessing I'll need a non-blocking connect(), then a call to select() with a timeout specified of 5 seconds or whatever I choose, and if select() errors after that 5 seconds the host is assumed not alive.

Only problem is I have no idea how to do the whole non-blocking thing Thanks.