Boost C++ Libraries: Ticket #5285: problem about boost::asio::ip::tcp::resolver https://svn.boost.org/trac10/ticket/5285 <blockquote> <p> one day i found a bug in my project, that's one of async_resolve's callback never called. i checked this problem and repeat this problem as following program: </p> </blockquote> <pre class="wiki"> #include "stdafx.h" #include &lt;boost/asio.hpp&gt; #include &lt;boost/bind.hpp&gt; #include &lt;boost/system/error_code.hpp&gt; #include &lt;stdio.h&gt; using namespace boost::asio; using namespace boost; class client { public: client(io_service&amp; ios): m_ios(ios), m_resolver(ios) { ip::tcp::resolver* resolver = new ip::tcp::resolver(m_ios); delete resolver; ip::tcp::resolver::query query("www.baidu.com","80"); m_resolver.async_resolve(query,boost::bind(&amp;client::handle_resolve,this,_1,_2)); } void handle_resolve(const system::error_code&amp; ec,ip::tcp::resolver_iterator it) { puts("see me?"); } io_service&amp; m_ios; ip::tcp::resolver m_resolver; }; int _tmain(int argc, _TCHAR* argv[]) { io_service ios; client* c = new client(ios); ios.run(); return 0; } </pre><p> i digged into the source code( in function boost.asio.detail.resolver_service.destroy ) it seems when i delete a temporary created resolver, the resolver's work service will be stopped. and thus client::handle_resolve will never be called. </p> <blockquote> <p> thx </p> </blockquote> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/5285 Trac 1.4.3 chris_kohlhoff Wed, 16 Mar 2011 01:21:04 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/5285#comment:1 https://svn.boost.org/trac10/ticket/5285#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">worksforme</span> </li> </ul> <p> I cannot reproduce any issue with 1.45 or the trunk. Note that you are leaking the client object. You need to destroy it before returning from main(). If you still experience the issue after fixing that, please supply more detailed information about how you build the program. </p> <p> N.B. to the best of my knowledge, the resolver_service::destroy() function has always been empty. </p> Ticket