[asio]remote_endpoint throws exception
Hi, I wrote TCP client program using boost::asio. OS: Debian GNU/Linux (x86_64) Boost: 1.49 I use asio::ip::tcp::socket::async_conect function and I called ip::tcp::socket::remote_endpoint at async_connect callback. Like this: // async_resolve handler void my_class::handle_resolve(const boost::system::error_code& error, boost::asio::ip::tcp::resolver::iterator endpoint_iterator) { if (!error) { socket_.async_connect(endpoint, strand_.wrap(...)); } } void my_class::handle_connect(const boost::system::error_code& error, boost::asio::ip::tcp::resolver::iterator endpoint_iterator) { if (!error) { // socket_ is my_class member. socket_.remote_endpoint(); // throw exception ! } ... } ip::tcp::socket::remote_endpoint sometime throws boost::system::system_error exception (error message is "remote_endpoint: Transport endpoint is not connected"). But async_connect is successfully completed. Why does remote_endpoint function throw exception? Thank you,
On 06/12/2014 01:18 PM, higashiyama@ncad.co.jp wrote:
ip::tcp::socket::remote_endpoint sometime throws boost::system::system_error exception (error message is "remote_endpoint: Transport endpoint is not connected"). But async_connect is successfully completed. Why does remote_endpoint function throw exception?
Sounds similar to this bug report (although it refers to a newer version of Boost) https://svn.boost.org/trac/boost/ticket/8795
On Sunday, June 15, 2014 08:17 PM, Bjorn Reese wrote:
On 06/12/2014 01:18 PM, higashiyama@ncad.co.jp wrote:
ip::tcp::socket::remote_endpoint sometime throws boost::system::system_error exception (error message is "remote_endpoint: Transport endpoint is not connected"). But async_connect is successfully completed. Why does remote_endpoint function throw exception?
Sounds similar to this bug report (although it refers to a newer version of Boost)
Quite. I can't say for sure whether it was working on 1.49 or not, but it looks like I was using async_connect back at that time and only noticed the regression at 1.54. Ben
Thank you for your advice, always. I will use 1.55. On 2014/06/16, at 11:05, benpope81@gmail.com wrote:
On Sunday, June 15, 2014 08:17 PM, Bjorn Reese wrote:
On 06/12/2014 01:18 PM, higashiyama@ncad.co.jp wrote:
ip::tcp::socket::remote_endpoint sometime throws boost::system::system_error exception (error message is "remote_endpoint: Transport endpoint is not connected"). But async_connect is successfully completed. Why does remote_endpoint function throw exception?
Sounds similar to this bug report (although it refers to a newer version of Boost)
Quite. I can't say for sure whether it was working on 1.49 or not, but it looks like I was using async_connect back at that time and only noticed the regression at 1.54.
Ben
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (3)
-
Ben Pope
-
Bjorn Reese
-
higashiyama@ncad.co.jp