本文整理汇总了C++中TcpConnectionPtr::getPeerAddr方法的典型用法代码示例。如果您正苦于以下问题:C++ TcpConnectionPtr::getPeerAddr方法的具体用法?C++ TcpConnectionPtr::getPeerAddr怎么用?C++ TcpConnectionPtr::getPeerAddr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TcpConnectionPtr
的用法示例。
在下文中一共展示了TcpConnectionPtr::getPeerAddr方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onClose
void EchoServer::onClose(const TcpConnectionPtr &conn)
{
cout << "client : " << conn->getPeerAddr().toIp() << " : "
<< conn->getPeerAddr().toPort() << " close" << endl;
conn->shutdown();
}
示例2: onConnect
void EchoServer::onConnect(const TcpConnectionPtr &conn)
{
cout << "client : " << conn->getPeerAddr().toIp() << " : "
<< conn->getPeerAddr().toPort() << " on" << endl;
conn->send("hello, welcome to Echo Server!\r\nenter word to look for, or q to quit: ");
}
示例3: onTcpConnected
void AppBusiness::onTcpConnected(const TcpConnectionPtr& connection)
{
logger().writeFmt("onTcpConnected (%s) (ConnCount: %d)",
connection->getPeerAddr().getDisplayStr().c_str(),
connection->getServerConnCount());
connection->recv();
}
示例4: onTcpConnected
//-----------------------------------------------------------------------------
// 描述: 接受了一个新的TCP连接
//-----------------------------------------------------------------------------
void AppBusiness::onTcpConnected(const TcpConnectionPtr& connection)
{
logger().writeFmt("onTcpConnected (%s) (ConnCount: %d)",
connection->getPeerAddr().getDisplayStr().c_str(),
connection->getServerConnCount());
string msg = "Welcome to the simple echo server, type 'quit' to exit.\r\n";
connection->send(msg.c_str(), msg.length());
}
示例5: onTcpConnected
void ServerModule_Daytime::onTcpConnected(const TcpConnectionPtr& connection)
{
logger().writeFmt("onTcpConnected (%s) (ConnCount: %d)",
connection->getPeerAddr().getDisplayStr().c_str(),
connection->getServerConnCount());
string msg = DateTime::now().toDateTimeString() + "\n";
connection->send(msg.c_str(), msg.length());
}
示例6: onTcpConnected
void ServerModule_Chargen::onTcpConnected(const TcpConnectionPtr& connection)
{
logger().writeFmt("onTcpConnected (%s) (ConnCount: %d)",
connection->getPeerAddr().getDisplayStr().c_str(),
connection->getServerConnCount());
connection->setNoDelay(true);
connection->recv();
connection->send(message_.c_str(), message_.length());
}
示例7: onTcpConnected
//-----------------------------------------------------------------------------
// 描述: 接受了一个新的TCP连接
//-----------------------------------------------------------------------------
void AppBusiness::onTcpConnected(const TcpConnectionPtr& connection)
{
logger().writeFmt("onTcpConnected (%s) (ConnCount: %d)",
connection->getPeerAddr().getDisplayStr().c_str(),
connection->getServerConnCount());
//string msg = "Welcome to the simple echo server, type 'quit' to exit.\r\n";
//ConnetManager::instance().add(connection);
connection->recv(SELF_PACKET_SPLITTER, EMPTY_CONTEXT);
}
示例8: onTcpConnected
void AppBusiness::onTcpConnected(const TcpConnectionPtr& connection)
{
const int MAX_CONN_COUNT = 3;
logger().writeFmt("onTcpConnected (%s) (ConnCount: %d)",
connection->getPeerAddr().getDisplayStr().c_str(),
connection->getServerConnCount());
int connCount = connection->getServerConnCount();
if (connCount > MAX_CONN_COUNT)
{
logger().writeFmt("Too many connections. (ConnCount: %d)", connCount);
connection->disconnect();
}
else
{
string msg = "Welcome to the simple echo server, type 'quit' to exit.\r\n";
connection->send(msg.c_str(), msg.length());
}
}
示例9: onConnect
void onConnect(const TcpConnectionPtr &conn)
{
cout<<"New Client"<<conn->getPeerAddr().toIp()<<"Port"
<<conn->getPeerAddr().toPort()<<endl;
conn->sendString("hello");
}
示例10: onConnection
void EchoServer::onConnection(const TcpConnectionPtr &conn)
{
cout << conn->getPeerAddr().toIp() << " port: "
<< conn->getPeerAddr().toPort() << endl;
conn->send("Hello, welcome to Echo Server!!!\r\n");
}