title: System Error 955 when using resolver::async_resolve
body: <p>At times I get the <code>System Error 995</code> when using the <code>async_resolve</code> method from an <code>tcp::resolver</code>.
  The code below shows the relevant code lines.</p>
  
  <pre><code>#include &lt;boost/bind.hpp&gt;
  #include &lt;boost/asio.hpp&gt;
  
  #include &lt;iostream&gt;
  
  class connection
  {
  public:
      connection(boost::asio::io_service&amp; io_service)
          : m_resolver(io_service), m_socket(io_service)
          {
          }
  
      void async_connect(
              std::string const&amp; host,
              std::string const&amp; service,
              boost::asio::ip::tcp::socket::protocol_type tcp = boost::asio::ip::tcp::v4()
              )
          {
              m_resolver.async_resolve(
                      boost::asio::ip::tcp::resolver::query(tcp, host, service),
                      boost::bind(
                          &amp;connection::resolve_handler, 
                          this, 
                          boost::asio::placeholders::error,
                          boost::asio::placeholders::iterator
                          )
                      );
          }
  
  protected:
      virtual void on_connected(boost::system::error_code const&amp; connect_error)
      {
          if (!connect_error)
          {
              std::cout &lt;&lt; "Connection established. Endpoint: " &lt;&lt; m_socket.remote_endpoint()
                        &lt;&lt; std::endl;
          }
          else
              std::cout &lt;&lt; "error: " &lt;&lt; connect_error &lt;&lt; std::endl;
      }
  
  private:
      void connect_handler(boost::system::error_code const&amp; connect_error)
      {
          on_connected(connect_error);
      }
  
      void resolve_handler(
              boost::system::error_code const&amp; resolve_error,
              boost::asio::ip::tcp::resolver::iterator endpoint_iterator
              )
          {
              if (!resolve_error)
              {
                  m_socket.async_connect(
                          *endpoint_iterator,
                          boost::bind(
                              &amp;connection::connect_handler, 
                              this,
                              boost::asio::placeholders::error
                              )
                          );
              }
          }
  
  private:
      boost::asio::ip::tcp::socket m_socket;
      boost::asio::ip::tcp::resolver m_resolver;
  };
  
  int main()
  {
      boost::asio::io_service io_service;
  
      connection foo(io_service);
      foo.async_connect("www.google.de", "http");
  
      io_service.run();
      return 0;
  }
  </code></pre>
  
  <p>995 (0x3E3) - ERROR_OPERATION_ABORTED means:</p>
  
  <blockquote>
    <p>The I/O operation has been aborted because of either a thread exit or
    an application request.</p>
  </blockquote>
  
  <p>But I have no idea why. I think something goes out of scope but I don't know what exactly. Hope you can help me. Thanks in advance!</p>