本文整理汇总了C++中TcpConnectionPtr::peerAddress方法的典型用法代码示例。如果您正苦于以下问题:C++ TcpConnectionPtr::peerAddress方法的具体用法?C++ TcpConnectionPtr::peerAddress怎么用?C++ TcpConnectionPtr::peerAddress使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TcpConnectionPtr
的用法示例。
在下文中一共展示了TcpConnectionPtr::peerAddress方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onConnection
void onConnection(const TcpConnectionPtr& conn){
LOG_INFO << "FileServer - " << conn->peerAddress().toIpPort() << " -> "
<< conn->localAddress().toIpPort() << " is "
<< (conn->connected() ? "UP" : "DOWN");
if(conn->connected()){
LOG_INFO << "FileServer - Sending file " << g_file
<< " to " << conn->peerAddress().toIpPort();
conn->setHighWaterMarkCallback(onHighWaterMark, 64*1024);
string fileContent = readFile(g_file);
conn->send(fileContent);
conn->shutdown();
LOG_INFO << "FileServer - done";
}
}
示例2: OnConnection
void OnConnection(const TcpConnectionPtr& conn)
{
LOG_INFO << conn->localAddress().toIpPort() << " -> "
<< conn->peerAddress().toIpPort() << " is "
<< (conn->connected() ? "UP" : "DOWN");
if(conn->connected())
{
m_connection = conn;
if(g_aliveConnections.incrementAndGet() == g_connections)
{
LOG_INFO << "all connected";
}
else
{
m_connection.reset();
if(g_aliveConnections.incrementAndGet() == g_connections)
{
LOG_INFO << "all disconnected";
g_loop->quit();
}
}
}
}
示例3: onConnection
void onConnection(const TcpConnectionPtr& conn){
LOG_INFO << conn->localAddress().toIpPort() << " -> "
<< conn->peerAddress().toIpPort() << " is "
<< (conn->connected() ? "UP" : "DOWN");
if(!conn->connected())
loop_->quit();
}
示例4: onConnection
void Sender::onConnection(const TcpConnectionPtr& conn)
{
LOG_INFO << "EchoServer - " << conn->peerAddress().toIpPort() << " -> "
<< conn->localAddress().toIpPort() << " is "
<< (conn->connected() ? "UP" : "DOWN");
}
示例5: defaultConnectionCallback
NAMESPACE_ZL_NET_START
void defaultConnectionCallback(const TcpConnectionPtr& conn)
{
LOG_INFO("defaultConnectionCallback : [%s]<->[%s] [%s]\n", conn->localAddress().ipPort().c_str(),
conn->peerAddress().ipPort().c_str(), conn->connected() ? "UP" : "DOWN");
}
示例6:
void P2PServer::onConnection(const TcpConnectionPtr& conn)
{
cout << conn->localAddress().toIpPort() << " -> "
<< conn->peerAddress().toIpPort() << " is "
<< (conn->connected() ? "UP" : "DOWN")
<< endl;
}
示例7: onJsonConnection
/***************************************************
Description: 处理新的json连接或者连接断开情况
Input: conn:TCP连接
Output: 无
Return: 无
***************************************************/
void TCPServer::onJsonConnection(const TcpConnectionPtr &conn)
{
LOG_DEBUG <<"JSONConnection: " << conn->peerAddress().toIpPort() << " -> "
<< conn->localAddress().toIpPort() << " is "
<< (conn->connected() ? "UP" : "DOWN");
if(!conn->connected())
jsonCodec_.cleanup(conn);
}
示例8: onConnection
void onConnection(const TcpConnectionPtr& conn)
{
LOG_TRACE << conn->peerAddress().toString() << " -> "
<< conn->localAddress().toString() << " is "
<< (conn->connected() ? "UP" : "DOWN");
LOG_INFO << conn->getTcpInfoString();
// conn->send("hello\n");
}
示例9:
std::vector<std::string> *tcp_server::connectedAddresses()
{
mConnectedAddresses.clear();
for (TcpServer::ConnectionMap::iterator it(server_.connections_.begin()); it != server_.connections_.end(); ++it)
{
TcpConnectionPtr conn = it->second;
mConnectedAddresses.push_back(conn->peerAddress().toIp());
}
return &mConnectedAddresses;
}
示例10: onServerConnection
/***************************************************
Description: 处理新的TCP连接或断开
Input: 无
Output: 无
Return: 无
***************************************************/
void TCPServer::onServerConnection(const TcpConnectionPtr& conn)
{
conn->setTcpNoDelay(true);
LOG_INFO << conn->peerAddress().toIpPort() << " -> "
<< conn->localAddress().toIpPort() << " is "
<< (conn->connected() ? "UP" : "DOWN");
if(!conn->connected())
{
clearConnectionInfo(conn);
}
}
示例11: onClientConnection
void ZGWServer::onClientConnection(const TcpConnectionPtr& conn)
{
LOG_INFO << "Client " << conn->peerAddress().toIpPort() << " -> "
<< conn->localAddress().toIpPort() << " is "
<< (conn->connected() ? "UP" : "DOWN");
if( conn->connected() )
{
int id = -1;
if( !idQueue_.empty() )
{
id = idQueue_.front();
idQueue_.pop();
id2conn_[id] = conn;
}
if( -1 == id )
{
LOG_ERROR << "[过载保护]系统到达最大连接数,拒绝连接";
conn->shutdown();
}
else
{
conn->setContext(id);
LOG_INFO << "新连接[" << conn->peerAddress().toIpPort() << "]流水ID: " << id;
}
}
else
{
if(!conn->getContext().empty())
{
int id = boost::any_cast<int>(conn->getContext());
assert(id > 0 && id <= static_cast<int>(kMaxConns));
// 回收连接的key
idQueue_.push(id);
id2conn_.erase(id);
}
}
}
示例12: serverConnectionCallback
void serverConnectionCallback(const TcpConnectionPtr& conn)
{
LOG_TRACE << conn->name() << " " << conn->peerAddress().toIpPort() << " -> "
<< conn->localAddress().toIpPort() << " is "
<< (conn->connected() ? "UP" : "DOWN");
if (conn->connected())
{
conn->setTcpNoDelay(true);
}
else
{
}
}
示例13: onConnection
void onConnection(const TcpConnectionPtr& conn)
{
cout << conn->peerAddress().ipPort() << " -> " << conn->localAddress().ipPort()
<< " is " << (conn->connected() ? "UP" : "DOWN") << "\n";
clientConnection = conn;
if (conn->connected())
{
//conn->setNoDelay(true);
}
else
{
//clientConnection.reset();
}
}
示例14: clientConnectionCallback
void clientConnectionCallback(const TcpConnectionPtr& conn)
{
LOG_TRACE << conn->localAddress().toIpPort() << " -> "
<< conn->peerAddress().toIpPort() << " is "
<< (conn->connected() ? "UP" : "DOWN");
if (conn->connected())
{
clientConnection = conn;
conn->setTcpNoDelay(true);
}
else
{
clientConnection.reset();
}
}
示例15: onConnection
void MyTcpClient::onConnection(const TcpConnectionPtr& conn)
{
LOG_INFO << conn->localAddress().toIpPort() << " -> "
<< conn->peerAddress().toIpPort() << " is "
<< (conn->connected() ? "UP" : "DOWN");
MutexLockGuard lock(mutex_);
if (conn->connected())
{
connection_ = conn;
}
else
{
connection_.reset();
}
}