title: How to set winsock accept function timeout?
body: <p>I'm on my way to write a win32 console application that act as a server. I have to set a timeout to accept function, like without connection in 10s the port shutdown. As I know, there's some way here:</p>
  
  <ol>
  <li><p>Async way. But I'm writing a console application so I can't use that wsaasyncselect function.</p></li>
  <li><p>With select function. But there's word that this way is not safe. If a client sent a RST package and then it offline, the select function think that this socket is still readable, and the accept function will be hold there forever.</p></li>
  <li><p>With alarm function. Firstly I try not to use it because it's unexpected in such a application, secondly I'm worried about whether it's threadsafe or not.</p></li>
  </ol>
  
  <p>So here I'm asking you sincerely to find a way to let the accept function timeout, who must be threadsafe, and better a nice way.</p>