Igor R:
the actual problem is this: sometimes, after a socket is deleted, instead of oustanding read/write operations returning with asio::error::operation_aborted, they return with no error (error==0), but with socket.native() equal to -1.
Those operations probably had completed *just before* you closed the socket...
so, if i understand correctly, there are pending calls for these events on the io_service queue, and when the socket is deleted, these calls are not removed? if so, how do i fix this? or more generally: how can i safely release an object holding a socket while there may be outstanding i/o operations? i've looked through the asio documentation, but i don't see anything about this in the tutorial or the example programs. i had assumed that socket::cancel() was the right solution to this, but it seems this is not the case... - river.