title: Should I implement my own TCP/IP socket timeouts?
body: <p>The software I'm working on needs to be able to connect to many servers in a short period of time, using TCP/IP. The software runs under Win32. If a server does not respond, I want to be able to quickly continue with the next server in the list.</p>
  
  <p>Sometimes when a remote server does not respond, I get a connection timeout error after roughly 20 seconds. Often the timeout comes quicker.</p>
  
  <p>My problem is that these 20 seconds hurts the performance of my software, and I would like my software to give up sooner (after say 5 seconds). I assume that the TCP/IP stack (?) in Windows automatically adjusts the timeout based on some parameters?</p>
  
  <p>Is it sane to override this timeout in my application, and close the socket if I'm unable to connect within X seconds? </p>
  
  <p>(It's probably irrelevant, but the app is built using C++ and uses I/O completion ports for asynchronous network communication)</p>