Esempio n. 1
0
 void
 on_accept(error_code ec)
 {
     if(! acceptor_.is_open())
         return;
     maybe_throw(ec, "accept");
     static int id_ = 0;
     std::thread{lambda{++id_, *this, std::move(sock_)}}.detach();
     acceptor_.async_accept(sock_,
         std::bind(&http_sync_server::on_accept, this,
             asio::placeholders::error));
 }
    // Called when receiving an incoming connection
    void on_accept(error_code ec)
    {
        // This can happen during exit
        if(! acceptor_.is_open())
            return;

        // This can happen during exit
        if(ec == boost::asio::error::operation_aborted)
            return;

        if(ec)
            fail("accept", ec);

        // Create the connection and run it
        std::make_shared<connection>(*this, ep_, std::move(sock_))->run();

        // Initiate another accept
        do_accept();
    }
Esempio n. 3
0
inline bool
TcpChannel::isListening() const
{
  return m_acceptor.is_open();
}