本文整理汇总了C++中socket_ptr::reset方法的典型用法代码示例。如果您正苦于以下问题:C++ socket_ptr::reset方法的具体用法?C++ socket_ptr::reset怎么用?C++ socket_ptr::reset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类socket_ptr
的用法示例。
在下文中一共展示了socket_ptr::reset方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: async_connect_handler
/// 连接回调
void tcp_connector::async_connect_handler( boost::system::error_code const& ec
, socket_ptr pSock, FactoryFunc fact_func, ConnectHandler const& handler
, options_ptr opts, tcp::resolver::iterator resolver_it )
{
tcp_session_ptr ptr;
boost::system::error_code remote_ec, local_ec;
if (!ec && pSock->remote_endpoint(remote_ec) != pSock->local_endpoint(local_ec)
&& !remote_ec && !local_ec)
ptr = fact_func(pSock, session_initialized(session_id(), group_id(), opts));
else if (tcp::resolver::iterator() != resolver_it)
{
boost::system::error_code close_ec;
pSock->close(close_ec);
if (close_ec)
pSock.reset(new socket(m_ios));
tcp::endpoint endpoint = *resolver_it++;
pSock->async_connect(endpoint
, boost::bind(&tcp_connector::async_connect_handler, this, placeholders::error
, pSock, fact_func, handler, opts, resolver_it ));
return ;
}
handler(ptr, ec);
}
示例2: do_accept
void server::do_accept() {
try {
socket_.reset(
new boost::asio::ip::tcp::socket(
io_service_pool_.get_io_service()));
acceptor_.async_accept(*socket_,
[this](boost::system::error_code ec)
{
if (!acceptor_.is_open())
{
return;
}
if (!ec)
{
connection_manager_.start(std::make_shared<connection>(
std::move(*socket_), connection_manager_, request_handler_));
}
do_accept();
});
} catch (std::exception & ex) {
std::cout << "do_accept error:" << ex.what() << std::endl;
return;
}
}
示例3: handle_accept
void network_impl::handle_accept(socket_ptr socket)
{
tcp::endpoint remote_endpoint = socket->remote_endpoint();
log_debug() << "New incoming connection from "
<< remote_endpoint.address().to_string();
channel_handle chanid = create_channel(socket);
kernel_->handle_connect(chanid);
socket.reset(new tcp::socket(*service()));
acceptor_->async_accept(*socket,
std::bind(&network_impl::handle_accept, shared_from_this(),
socket));
}