[boost::asio] exception not passed to async callback

Hello list, Right now i am having some problems with a TCP socket waiting for a pending async read operation. When the remote endpoint closes the connection due to some crash or other unexpected situation(i.e, without proper closing of the socket) my application is terminated with this message: "Terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::system::system_error>
' what(): Transport endpoint is not connected Aborted"
Maybe i am missing something here, because i expected any boost::system exceptions to be passed to the callback associated with the async read operation. I am assuming that this exception is thrown in the io_service::run method, is that right? If so, why it is not passed to the callback? and what can i do to catch it, having the io_service::run running on a separeted thread? Thanx in advance and best regards, -- Matheus Araújo Aguiar Computer Scientist matheus.pit@gmail.com

Right now i am having some problems with a TCP socket waiting for a pending async read operation. When the remote endpoint closes the connection due to some crash or other unexpected situation(i.e, without proper closing of the socket) my application is terminated with this message: "Terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::system::system_error>
' what(): Transport endpoint is not connected Aborted"
Maybe i am missing something here, because i expected any boost::system exceptions to be passed to the callback associated with the async read operation.
To be more exact, error_code is passed to the handler.
I am assuming that this exception is thrown in the io_service::run method, is that right? If so, why it is not passed to the callback? and what can i do to catch it, having the io_service::run running on a separeted thread?
I never encountered such behaviour, but you always can "wrap" io_service::run() with your own thread-function and catch exceptions: void thread_func(io_service *io) { try { io->run(); } catch(.........) { } } //... thread t(&thread_func, &io_);

On Mon, Mar 8, 2010 at 8:41 PM, Igor R <boost.lists@gmail.com> wrote:
Right now i am having some problems with a TCP socket waiting for a pending async read operation. When the remote endpoint closes the connection due to some crash or other unexpected situation(i.e, without proper closing of the socket) my application is terminated with this message: "Terminate called after throwing an instance of
'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::system::system_error>
' what(): Transport endpoint is not connected Aborted"
Maybe i am missing something here, because i expected any boost::system exceptions to be passed to the callback associated with the async read operation.
To be more exact, error_code is passed to the handler.
I am assuming that this exception is thrown in the io_service::run method, is that right? If so, why it is not passed to the callback? and what can i do to catch it, having the io_service::run running on a separeted thread?
I never encountered such behaviour, but you always can "wrap" io_service::run() with your own thread-function and catch exceptions:
void thread_func(io_service *io) { try { io->run(); } catch(.........) { } } //... thread t(&thread_func, &io_); _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Thank you Igor, I will certainly try that. Regards, -- Matheus Araújo Aguiar Computer Scientist matheus.pit@gmail.com
participants (2)
-
Igor R
-
Matheus Araújo Aguiar