
Christopher Yeleighton
May I call socket::cancel in a signal handler?
Rather acceptor::cancel; the idea is to cancel the listener in the signal handler. May I?
How do I dispose of the open session objects?
Calling io_session::stop does not cancel pending tasks, it just destroys them. Therefore all cleanup code should be in the destructor of the session object and thus the async TCP echo server example code is wrong. Session objects are not of value type because they contain a socket, which is a resource that cannot be copied. Therefore they cannot be passed by value. The reference to a session objects must be a value type; boost::shared_ptr is well suited for this task (std::auto_ptr is a resource type too). And indeed, the async TCP daytime server example does use boost::shared_ptr; why the async TCP echo server recourses to quirks like { if (error) delete this; } is beyond my understanding. The example is misleading and should be fixed. Chris