当前位置: 首页>>代码示例>>C++>>正文


C++ endpoint::protocol方法代码示例

本文整理汇总了C++中tcp::endpoint::protocol方法的典型用法代码示例。如果您正苦于以下问题:C++ endpoint::protocol方法的具体用法?C++ endpoint::protocol怎么用?C++ endpoint::protocol使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tcp::endpoint的用法示例。


在下文中一共展示了endpoint::protocol方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: listener

    listener(
        boost::asio::io_context& ioc,
        tcp::endpoint endpoint)
        : acceptor_(ioc)
        , socket_(ioc)
    {
        boost::system::error_code ec;

        // Open the acceptor
        acceptor_.open(endpoint.protocol(), ec);
        if(ec)
        {
            fail(ec, "open");
            return;
        }

        // Bind to the server address
        acceptor_.bind(endpoint, ec);
        if(ec)
        {
            fail(ec, "bind");
            return;
        }

        // Start listening for connections
        acceptor_.listen(
            boost::asio::socket_base::max_listen_connections, ec);
        if(ec)
        {
            fail(ec, "listen");
            return;
        }
    }
开发者ID:miguelportilla,项目名称:Beast,代码行数:33,代码来源:websocket_server_async.cpp

示例2: connect

bool TajoSyncClient::connect(const tcp::endpoint &endpoint,
        std::string &errmsg)
{
    boost::system::error_code ec;

    pImpl_->socket_.open(endpoint.protocol(), ec);

    if( !ec )
    {
        pImpl_->socket_.set_option(tcp::no_delay(true), ec);

        if( !ec )
        {
            pImpl_->socket_.connect(endpoint, ec);
        }
    }

    if( !ec )
    {
		pImpl_->state_ = TajoClientState::CONNECTED;
        return true;
    }
    else
    {
        errmsg = ec.message();
        return false;
    }
}
开发者ID:shyblue,项目名称:tajo-client-cpp,代码行数:28,代码来源:tajo_sync_client.cpp

示例3: Start

 void Server::Start(tcp::endpoint endpoint)
 {
     _acceptor.open(endpoint.protocol());
     _acceptor.set_option(tcp::acceptor::reuse_address(true));
     _acceptor.bind(endpoint);
     _acceptor.listen();
     
     _StartAccept();
     
     sLog.Info(LOG_STRATUM, "Stratum server started");
 }
开发者ID:ahmedbodi,项目名称:poolserver,代码行数:11,代码来源:Server.cpp

示例4: acceptWait

	void seedArm_service_impl::acceptWait(const std::string& addr, const std::string& port
		, size_t workerThreadsCount
		, const size_t keepAliveMilliseconds_GlobalValue)
	{
		if (0 == workerThreadsCount){
			workerThreadsCount = boost::thread::hardware_concurrency();
		}

		////////////////////////////////////////////////
		// set common keepAliveTime
		connection_impl::KEEP_ALIVE_TIME_MS = keepAliveMilliseconds_GlobalValue;



		using TCP = boost::asio::ip::tcp;

		////////////////////////////////////////////////
		// ready accpetor
		TCP::resolver resolver(_ios);
		TCP::resolver::query quary(addr, port);
		TCP::endpoint endpoint = *resolver.resolve(quary);

		_acceptor.open(endpoint.protocol());

		_acceptor.set_option(TCP::no_delay(true));
		_acceptor.set_option(TCP::acceptor::reuse_address(true));
		_acceptor.bind(endpoint);
		_acceptor.listen();

		_acceptConn = connection::ptr(new connection_impl(this, _ios), connection_impl::destruct);
		_acceptor.async_accept(_acceptConn->socket(), _strand.wrap(
			boost::bind(&seedArm_service_impl::accept, this, boost::asio::placeholders::error)));


		////////////////////////////////////////////////
		// ready worker
		for (size_t i = 0; i < workerThreadsCount; ++i)
		{
			boost::shared_ptr<boost::thread> thread(new boost::thread(
				boost::bind(&boost::asio::io_service::run, &_ios)));

			s_threads.push_back(thread);
		}


		////////////////////////////////////////////////
		// ready expireTimer
		_prevTime = boost::chrono::system_clock::now();
		_updater.expires_from_now(boost::posix_time::milliseconds(UPDATE_TIME_MS));

		_updater.async_wait(_strand.wrap(
			boost::bind(&seedArm_service_impl::update, this, boost::asio::placeholders::error)));
	}
开发者ID:SeedArm,项目名称:SeedArmNet,代码行数:53,代码来源:seedArm_service_impl.cpp

示例5: add_endpoint

void worker::add_endpoint(tcp::endpoint& ep, bs::error_code& ec) {
    try {
        auto acceptor = tcp::acceptor(m_iosvc);
        acceptor.open(ep.protocol());
        acceptor.set_option(tcp::acceptor::reuse_address(true));
        acceptor.bind(ep);
        int backlog = options::opts["server.backlog"].as<int>();
        if (backlog == 0) {
            backlog = ba::socket_base::max_connections;
        }
        acceptor.listen(backlog);
        m_acceptors.push_back(std::move(acceptor));
    } catch (bs::system_error& e) {
        ec = e.code();
    }
}
开发者ID:apohl79,项目名称:petrel,代码行数:16,代码来源:worker.cpp

示例6: fail

    /** Open a listening port.

        @param ep The address and port to bind to.

        @param ec Set to the error, if any occurred.
    */
    void
    open(tcp::endpoint const& ep, error_code& ec)
    {
        acceptor_.open(ep.protocol(), ec);
        if(ec)
            return fail("open", ec);
        acceptor_.set_option(
            boost::asio::socket_base::reuse_address{true});
        acceptor_.bind(ep, ec);
        if(ec)
            return fail("bind", ec);
        acceptor_.listen(
            boost::asio::socket_base::max_connections, ec);
        if(ec)
            return fail("listen", ec);
        do_accept();
    }
开发者ID:vinniefalco,项目名称:Beast,代码行数:23,代码来源:websocket_server_async.cpp

示例7: listener

    listener(
        boost::asio::io_context& ioc,
        ssl::context& ctx,
        tcp::endpoint endpoint)
        : ctx_(ctx)
        , acceptor_(ioc)
        , socket_(ioc)
    {
        boost::system::error_code ec;

        // Open the acceptor
        acceptor_.open(endpoint.protocol(), ec);
        if(ec)
        {
            fail(ec, "open");
            return;
        }

        // Allow address reuse
        acceptor_.set_option(boost::asio::socket_base::reuse_address(true), ec);
        if(ec)
        {
            fail(ec, "set_option");
            return;
        }

        // Bind to the server address
        acceptor_.bind(endpoint, ec);
        if(ec)
        {
            fail(ec, "bind");
            return;
        }

        // Start listening for connections
        acceptor_.listen(
            boost::asio::socket_base::max_listen_connections, ec);
        if(ec)
        {
            fail(ec, "listen");
            return;
        }
    }
开发者ID:LocutusOfBorg,项目名称:poedit,代码行数:43,代码来源:websocket_server_async_ssl.cpp


注:本文中的tcp::endpoint::protocol方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。