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


C++ TcpConnectionPtr::peerAddress方法代码示例

本文整理汇总了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";
    }
}
开发者ID:xujie-nm,项目名称:learnMuduo,代码行数:14,代码来源:download.cpp

示例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();
    		}
    	}
    }
	}
开发者ID:adan830,项目名称:kimgbo,代码行数:25,代码来源:filetransfer.cpp

示例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();
 }
开发者ID:xujie-nm,项目名称:learnMuduo,代码行数:7,代码来源:chargenclient.cpp

示例4: onConnection

void Sender::onConnection(const TcpConnectionPtr& conn)
{
	  LOG_INFO << "EchoServer - " << conn->peerAddress().toIpPort() << " -> "
           << conn->localAddress().toIpPort() << " is "
           << (conn->connected() ? "UP" : "DOWN");
	  
}
开发者ID:crspecter,项目名称:network_ydxlib,代码行数:7,代码来源:ydx_sender.cpp

示例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");
}
开发者ID:YuuFish,项目名称:zl_reactor,代码行数:7,代码来源:TcpConnection.cpp

示例6:

void P2PServer::onConnection(const TcpConnectionPtr& conn)
{
  cout << conn->localAddress().toIpPort() << " -> "
       << conn->peerAddress().toIpPort() << " is "
       << (conn->connected() ? "UP" : "DOWN") 
       << endl;

}
开发者ID:albus2012,项目名称:HUAWEIP2P,代码行数:8,代码来源:p2pserver.cpp

示例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);
}
开发者ID:zcdoyle,项目名称:RemoteControl,代码行数:15,代码来源:server.cpp

示例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");
  }
开发者ID:lilothar,项目名称:walle,代码行数:9,代码来源:test_service.cpp

示例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;
}
开发者ID:Will-tm,项目名称:Pixel-Styles-Host,代码行数:10,代码来源:tcp_server.cpp

示例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);
    }
}
开发者ID:zcdoyle,项目名称:RemoteControl,代码行数:18,代码来源:server.cpp

示例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);
        }
    }
}
开发者ID:zhangnian,项目名称:zgw,代码行数:40,代码来源:zgw.cpp

示例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
  {
  }
}
开发者ID:adan830,项目名称:kimgbo,代码行数:13,代码来源:roundtrip.cpp

示例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();
     }
 }
开发者ID:lizhenghn123,项目名称:zl_reactor,代码行数:14,代码来源:TcpClient_test.cpp

示例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();
  }
}
开发者ID:adan830,项目名称:kimgbo,代码行数:15,代码来源:roundtrip.cpp

示例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();
    }
}
开发者ID:catxuxiang,项目名称:SocketTest,代码行数:16,代码来源:mytcpclient.cpp


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