示例#1
0
void Server::accept()
{
    Session::ptr newSession = Session::create(m_acceptor.get_io_service(), this->m_cfg);
    boost::shared_ptr<protocol::Demuxer> demuxer(new protocol::Demuxer(newSession));
    newSession->setDemuxer(demuxer);

    m_acceptor.async_accept(newSession->socket(),
                            boost::bind(&Server::acceptHandler, this, newSession,
                                        boost::asio::placeholders::error));
}
示例#2
0
void Server::accept()
{
	for (;;)
	{
		Session::ptr newSession = Session::create(m_acceptor.get_io_service(), this->m_cfg);
		boost::shared_ptr<protocol::Demuxer> demuxer(new protocol::Demuxer(newSession));
		newSession->setDemuxer(demuxer);

    m_acceptor.accept(newSession->socket());
		boost::thread t(boost::bind(&Session::start, newSession));
	}
}
示例#3
0
文件: proxy.cpp 项目: respu/proxy
void proxy::handle_accept(
        const boost::system::error_code& ec,
        session::ptr session_ptr)
{
    if (!ec)
    {
        if (session_ptr)
        {
            LOG_INFO() << "connection accepted";

            session_ptr->start();

            sessions_.push_back(session_ptr);
        }

        session::ptr ptr = boost::make_shared<session>(
                    boost::ref(io_service_),
                    to_.host_name(),
                    to_.service_name(),
                    buffer_size_);

        acceptor_.async_accept(
                    ptr->get_socket(),
                    boost::bind(
                        &proxy::handle_accept,
                        this,
                        placeholders::error,
                        ptr));

    }
    else
    {
        LOG_ERROR() << "ec=[" << ec << "] message=[" << ec.message() << "]";
    }
}
示例#4
0
void Server::acceptHandler(Session::ptr new_Session, const boost::system::error_code& error)
{
    if (!error)
    {
        new_Session->start();
    }

    accept();
}
示例#5
0
void BasicService::do_async_accept() {
    Session::ptr sp = new Session(service);
    srv_acceptor.async_accept(sp->socket(), boost::bind(&BasicService::handle_accept, this, _1, sp));
}