connect
is failing with WSAETIMEDOUT
. That's fine but is there anyway to make the timeout period shorter? Maybe something like 2-3 seconds? Currently it seems to be something higher like 10 seconds.
OS is Windows, using Winsock with C++
connect
is failing with WSAETIMEDOUT
. That's fine but is there anyway to make the timeout period shorter? Maybe something like 2-3 seconds? Currently it seems to be something higher like 10 seconds.
OS is Windows, using Winsock with C++
Put the socket into non-blocking mode before calling connect()
. When it returns with a WSAEWOULDBLOCK
error, call select()
with whatever timeout interval you want. If select()
reports the socket becomes writable, the connection was successful. If select()
reports a timeout instead, close the socket.
This has been asked before: WINSOCK - Setting a timeout for a connection attempt on a non existing IP?
No, it's handled by the IP stack. You'll have to start a timer and kill the connection if you need to change this functionality.