Is there any way to decrease the timeout when I call connect() function from Winsock? I think it's almost 30 seconds, I want to put 5 seconds.
The easiest way is to use the socket in non-blocking mode while connecting, and use select()
with a timeout of 5 seconds to check if the socket is writable. After select()
exits, the connection is either established or not. If not, consider the connection timed out and perform error handling as needed.