HI
   
 Now when someone disconnects the CConnection its freed from memory, this disconnection seems to cause the IOCP to complete immediately.  So the callback gets called again.  The problem I'm having is that the pOverlapped pointer seems to be valid however the pConnection pointer contains junk - ( I freed the memory it points to) , so when I try to 'Do Something' with the pointer it cause the first chance exception.  Now since the app doesn't crash and I only get a first chance exception I'm assuming that the OS catches it... 
 
 
 
I've been thinking about this.  All callbacks must be protected by some sort of exception handling in the OS.  If you were to do something silly in a callback resulting in a crash and since it is Windows that calls the function then Windows would crash without it.
 
Why don't you wait until the IOCP completion for disconnection is posted, and then free the connection object
 
I guess the way to do that would be to just close the socket and then free the memory in the callback....
 
(or better yet, destroy it and return its memory to your memory pool to save an allocation for the next connection object)?
 
An even better suggestion.
 
Thanks for your help
Max

Reply via email to