title: How to accept socket with timeout
body: <p>Is there is a timeout crossplatform soulution to accept client using <code>accept</code> function without setting socket to non-blocking?</p>
  
  <p>I know that i should use <code>select</code> function to it, but what i'm doing wrong?</p>
  
  <pre><code>SOCKET NativesAcceptClient(SOCKET s, int timeout)
  {
     int iResult;
     struct timeval tv;
     fd_set rfds;
     FD_ZERO(&amp;rfds);
     FD_SET(s, &amp;rfds);
  
     tv.tv_sec = (long)timeout;
     tv.tv_usec = 0;
  
     iResult = select(s, &amp;rfds, (fd_set *) 0, (fd_set *) 0, &amp;tv);
     if(iResult &gt; 0)
     {
        return accept(s, NULL, NULL);
     }
     else
     {
       //always here, even if i connect from another application
     }
     return 0;
  }
  </code></pre>
  
  <p>How to fix that?
  Thanks!</p>