
Do I need to do anything special to catch an error from a boost asio async method? Or can I just wrap the method (eg: async_write) in a try/catch? (Since the initial call may be fine, but later on, an async call fails and I'm already out of the try/catch block) thanks, billy

Hi! Billy Chasen schrieb:
Or can I just wrap the method (eg: async_write) in a try/catch? (Since the initial call may be fine, but later on, an async call fails and I'm already out of the try/catch block)
You cannot wrap the async_write call to catch the error. Instead the async_write takes a WriteHandler which is called on completion of the write operation. This handler takes a parameter of type error_code which is used to signal errors. See http://www.boost.org/doc/libs/1_35_0/doc/html/boost_asio/reference/async_wri... and http://www.boost.org/doc/libs/1_35_0/doc/html/boost_asio/reference/WriteHand... Regards, Frank
participants (2)
-
Billy Chasen
-
Frank Birbacher