title: Boost ASIO async acceptor not opening a listening port
body: <p>OS : linux 64 bit ARCH.</p>
  
  <p>BOOST : 1.46.1</p>
  
  <p>COMPILER : clang++ / GCC.</p>
  
  <p>I have a code fragment that has the wire up of a tcp acceptor modelled on a boost::asio example (<a href="http://www.boost.org/doc/libs/1_46_1/doc/html/boost_asio/example/chat/chat_server.cpp" rel="nofollow">Chat Server</a>). However, when I run the fragment, No listening TCP socket shows up in a netstat listening(linux) . However, the chat server example, when compiled, does show up. Could someone please point out what I am doing wrong ? </p>
  
  <pre><code>#include &lt;boost/asio.hpp&gt;
  #include &lt;boost/shared_ptr.hpp&gt;
  #include &lt;boost/bind.hpp&gt;
  #include &lt;list&gt;
  #include &lt;iostream&gt;
  
  
  using namespace boost::asio;
    using namespace boost::asio::ip;
  
    class ClientConnection
    {
    public:
      ClientConnection(io_service &amp; io_s)
        : m_socket(io_s) {}
      tcp::socket &amp; socket() { return m_socket; }
    private:
      tcp::socket m_socket;  
    };
  
    typedef boost::shared_ptr&lt;ClientConnection&gt; client_connection_ptr;
  
    class ClientConnectionAcceptor
    {
    public:
      ClientConnectionAcceptor(unsigned short port)
        : m_io_service(),
          m_port(port),
          m_endpoint(tcp::v4(), m_port),
          m_acceptor(m_io_service, m_endpoint)
      {
        std::cout &lt;&lt; "acceptor is open : " &lt;&lt; m_acceptor.is_open() &lt;&lt; std::endl;
        client_connection_ptr ccp(new ClientConnection(m_io_service));
  
        m_acceptor.async_accept(  
          ccp-&gt;socket(),
          boost::bind(&amp;ClientConnectionAcceptor::handle_accept,this, 
          ccp, placeholders::error));
      } 
  
      void handle_accept(client_connection_ptr ccp, const boost::system::error_code &amp; error)
      {
        std::cout &lt;&lt; "in handle_accept" &lt;&lt; std::endl;  
        if(!error)
        {
         // m_rpc_oracle.AddNewClient(ccp);
          client_connection_ptr new_ccp(new ClientConnection(m_io_service));
          m_acceptor.async_accept(  
            new_ccp-&gt;socket(),
            boost::bind(&amp;ClientConnectionAcceptor::handle_accept,this, 
            ccp, placeholders::error));
  
        }
      }
  
      io_service &amp; io_service() { return m_io_service; }
    private:
      boost::asio::io_service m_io_service;
      tcp::endpoint m_endpoint;
      tcp::acceptor m_acceptor;
      unsigned short m_port;
    };
  
  
  int main()
  {
    ClientConnectionAcceptor acceptor(5000);
    acceptor.io_service().run();
  }    
  </code></pre>