
It seems to work fine for one or two connections, but if more connections are openend, boost suddenly crashes, mostly in the bind-template.hpp:
To be more exact, you application crashes ;).
template
result_type operator()(A1 const & a1, A2 const & a2) { list2 a(a1, a2); CRASH ===> BOOST_BIND_RETURN l_(type (), f_, a, 0); }
This is an invocation of some binder. In your case it's an invocation of a completion handler. It crashes because it's bound to a dead (i.e. deleted) object - which is apparently reasonable, since you don't use shared_from_this() idiom. Specifically in your code the problem is the following: 1) You issue 2 async.requests: socket_.async_read_some(..., boost::bind(&session::handle_read, this,...)); sqlsocket_.async_read_some(..., boost::bind(&session::handle_sqlserver_read, this, ...)); 2) One of the requests ends with an error (even just EOF), and you delete the connection object. 3) Now the completion handler of the seconds request is being invoked... crash. Conclusion: do not bind your handlers to "this", do not delete objects manually. Instead, use shared_from_this() idiom.