id,summary,reporter,owner,description,type,status,milestone,component,version,severity,resolution,keywords,cc 6138,ip::tcp::resolver::cancel problem,forever,chris_kohlhoff,"If connection is down, `boost::asio::ip::tcp::resolver::cancel' doesn't work properly by attemting to resolve a host using `boost::asio::ip::tcp::resolver::async_resolve'. Handler has invoked with the code `host_not_found_try_again' and not `operation_aborted'. Though it's documented that function forces the completion of any pending asynchronous operations on the host resolver, the handler for each cancelled operation will be invoked with the `boost::asio::error::operation_aborted' error code. [http://www.boost.org/doc/libs/1_48_0/doc/html/boost_asio/reference/ip__basic_resolver/cancel.html Link] {{{ #include #include int main() { boost::asio::io_service ios; boost::asio::deadline_timer timer(ios); boost::asio::ip::tcp::resolver resolver(ios); boost::asio::ip::tcp::resolver::query query(""google.ru"", ""http""); auto func = [&](const boost::system::error_code& e, boost::asio::ip::tcp::resolver::iterator it) { if ( e ) { std::cout << ""e: "" << e.message() << std::endl; } if ( it == boost::asio::ip::tcp::resolver::iterator() ) { std::cout << ""null iterator"" << std::endl; } if ( e || it == boost::asio::ip::tcp::resolver::iterator() ) { return; } for ( ; it != boost::asio::ip::tcp::resolver::iterator(); ++it) { std::cout << ""it: "" << it->endpoint() << std::endl; } }; resolver.async_resolve( query, func ); timer.expires_from_now(boost::posix_time::milliseconds(1000)); timer.async_wait( [&](const boost::system::error_code& error){ std::cout << ""timer expired"" << std::endl; resolver.cancel(); } ); ios.run(); } }}} ",Bugs,closed,To Be Determined,asio,Boost 1.48.0,Problem,invalid,,