本文整理汇总了C++中channel::ptr::address方法的典型用法代码示例。如果您正苦于以下问题:C++ ptr::address方法的具体用法?C++ ptr::address怎么用?C++ ptr::address使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类channel::ptr
的用法示例。
在下文中一共展示了ptr::address方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handle_accept
void protocol::handle_accept(const code& ec, channel::ptr node,
acceptor::ptr accept)
{
// Relisten for connections.
start_accept(ec, accept);
if (ec)
{
log_debug(LOG_PROTOCOL)
<< "Failure accepting connection: " << ec.message();
return;
}
if (inbound_connections_.size() >= max_inbound_)
{
log_debug(LOG_PROTOCOL)
<< "Rejected inbound connection due to connection limit";
return;
}
const auto address = node->address();
if (is_blacklisted(node->address()))
{
log_debug(LOG_PROTOCOL)
<< "Rejected inbound connection due to blacklisted address";
return;
}
if (is_loopback(node))
{
log_debug(LOG_PROTOCOL)
<< "Rejected inbound connection from self";
return;
}
// Save the connection as we are now assured of getting stop event.
inbound_connections_.push_back(node);
// Accepted!
log_info(LOG_PROTOCOL)
<< "Accepted connection from [" << address << "] ("
<< inbound_connections_.size() << " total)";
const auto stop_handler =
dispatch_.ordered_delegate(&protocol::inbound_channel_stopped,
this, _1, node, address.to_string());
start_talking(node, stop_handler, relay_);
}
示例2: handle_handshake
void protocol::handle_handshake(const code& ec, channel::ptr node)
{
if (ec)
{
log_debug(LOG_PROTOCOL) << "Failure in peer handshake ["
<< node->address() << "] " << ec.message();
node->stop(ec);
return;
}
// Attach ping protocol to the new connection (until node stop event).
std::make_shared<protocol_ping>(node, pool_, timeouts_.heartbeat)->start();
// Attach address protocol to the new connection (until node stop event).
std::make_shared<protocol_address>(node, pool_, hosts_, self_)->start();
}