6 Aug
2009
6 Aug
'09
3:16 p.m.
In ASIO, when I execute a cancel() on a tcp::socket, does it remove all of the handlers associated with the socket from the handler queue?
No. Every async_XXX request must end with its handler invocation. <...>
Let's assume now that the object destructs before the handleRead is called
Also, as reading and writing operations are done in the IO service thread, would it be safe to call the tcp::socket cancel from another
This is very bad and will cause crash/segfault. Parts of your handler (incl. the bound object) must not cease before the async.operation is complete. thread (e.g. in the destructor of a class)? No. You should post() the cancel operation to io_service thread.