
Hello, Dear All, I'm playing with Boost.ASIO framework and failed to find a complete answer on the following question. Under which circumstances is it guaranteed that asynchronous operation completion handler is called? Plainly speaking, is this example code correct? void my_handler(const error_code &ec) { if(!ec) { /* process successful operation */ } else { /* process failed operation */ } try { async_write(port, my_handler2) } catch(...) { // processing failure to execute asynchronous operation } } Obviously here I rely heavily upon the above mentioned guarantee. Looking at least at async_write() implementation, it cannot be relied upon: - async_write executes a chain of boost::asio::detail::write_op() operations: - if asio_handler_allocate() may throw then - write_op::stream_.async_write_some() may throw then - write_op.handler_() might never be called So, either we should never rely on this assumption, or there's a bug in async_write(). Not relying on this assumption what is the reliable way of building applications with Boost.Asio? Sincerely yours, Fedor Trushkin