Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>That's not how IOCPs work.</p> <p>If you have pending operations that you want to cancel then close the corresponding socket and the operations will either complete or fail and all of the completions (including the failures) will come out of the IOCP eventually.</p> <p>You need to wait for that to occur and once it has then you are good to shut down.</p> <p>What I tend to do is have a 'per connection' structure which contains the socket and which is used as the completion key. I then have "per operation" structures which include the <code>OVERLAPPED</code> and which also include details of which operation type, the I/O buffer used and other stuff. Both of these structures is reference counted.</p> <p>When an operation is initiated you increment the reference count on both the connection object and the operation object. When you get a completion you process it and then decrement the counts. When the counts reach 0 you're not doing any work with the objects and they can be recycled to the pool for reuse.</p> <p>To aid in clean shutdown I have a counter that I can wait on that tracks the number of 'active' 'per connection' objects (sockets). </p> <p>To shut down you abort all connections and then wait for the connection counter to hit zero. At that point all of your objects are either destroyed or in your pools and you can clean up.</p> <p>I have some example code, <a href="http://www.serverframework.com/products---the-free-framework.html" rel="nofollow">here</a>, which is a set of full featured IOCP server examples which may help - it's working code that you can step through and get ideas from if nothing else.</p>
    singulars
    1. This table or related slice is empty.
    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. VO
      singulars
      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