Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The basic idea is that, since you're using asynchronous I/O with the system thread pool, you shouldn't need to check for timeouts via events because you're not blocking any threads.</p> <p>The <a href="http://msdn.microsoft.com/en-us/magazine/cc302334.aspx" rel="nofollow">recommended way</a> to check for stale connections is to call <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms738544%28v=vs.85%29.aspx" rel="nofollow"><code>getsockopt</code></a> with the <code>SO_CONNECT_TIME</code> option. This returns the number of seconds that the socket has been connected. I know that's a poll operation, but if you're smart about how and when you query this value, it's actually a pretty good mechanism for managing connections. I explain below how this is done.</p> <p>Typically I'll call <code>getsockopt</code> in two places: one is during my completion callback (so that I have a timestamp for the last time that an I/O completion occurred on that socket), and one is in my accept thread.</p> <p>The accept thread monitors my socket backlog via <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms741576%28v=vs.85%29.aspx" rel="nofollow"><code>WSAEventSelect</code></a> and the <code>FD_ACCEPT</code> parameter. This means that the accept thread only executes when Windows determines that there are incoming connections that require accepting. At this time I enumerate my accepted sockets and query <code>SO_CONNECT_TIME</code> again for each socket. I subtract the timestamp of the connection's last I/O completion from this value, and if the difference is above a specified threshold my code deems the connection as having timed out.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload