title: how to determine whether boost async_accept is listening on a port or not
body: <p>I am unable to get this example working
  <a href="http://www.boost.org/doc/libs/1_61_0/doc/html/boost_asio/tutorial/tutdaytime3/src.html" rel="nofollow noreferrer">http://www.boost.org/doc/libs/1_61_0/doc/html/boost_asio/tutorial/tutdaytime3/src.html</a></p>
  
  <p>I have changed the port 13 to 1163 so that I don't need to be a root user to start listening.</p>
  
  <p>And I am running the <code>io_service</code> in separate thread.</p>
  
  <pre><code>int main()
  {
      try
      {
          boost::asio::io_service io_service;
          tcp_server server(io_service);
          boost::thread t(boost::bind(&amp;boost::asio::io_service::run, &amp;io_service));
          t.detach();
  
      }
      catch (std::exception&amp; e)
      {
          std::cerr &lt;&lt; e.what() &lt;&lt; std::endl;
      }
      string wait;
      cin &gt;&gt; wait;
      return 0;
  }
  </code></pre>
  
  <p>When testing the above server with <a href="http://www.boost.org/doc/libs/1_61_0/doc/html/boost_asio/tutorial/tutdaytime1/src.html" rel="nofollow noreferrer">http://www.boost.org/doc/libs/1_61_0/doc/html/boost_asio/tutorial/tutdaytime1/src.html</a> client, it says <code>connection refused</code>.</p>
  
  <p><code>netstat --listen</code> didn't show any open ports on 1163</p>
  
  <p>I couldn't figure out how to use <code>boost::asio::async_result&lt;typename Handler&gt;</code> I am confused on <code>Handler</code>.</p>
  
  <p><strong>Working modification</strong></p>
  
  <pre><code>int main()
  {
      try
      {
          boost::asio::io_service io_service;
          tcp_server server(io_service);
          boost::thread t(boost::bind(&amp;boost::asio::io_service::run, &amp;io_service));
          t.detach();
          string wait;
          cin &gt;&gt; wait;
      }
      catch (std::exception&amp; e)
      {
          std::cerr &lt;&lt; e.what() &lt;&lt; std::endl;
      }
  
      return 0;
  }
  </code></pre>
  
  <p>If the <code>wait</code> is inside the <code>try</code> block, the code working!</p>