本文整理汇总了C++中NetAddress::toIpPort方法的典型用法代码示例。如果您正苦于以下问题:C++ NetAddress::toIpPort方法的具体用法?C++ NetAddress::toIpPort怎么用?C++ NetAddress::toIpPort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NetAddress
的用法示例。
在下文中一共展示了NetAddress::toIpPort方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onConnected
void Robot::onConnected(Link *link, const NetAddress& localAddr, const NetAddress& peerAddr)
{
static int g_connectedRobotCnt = 0;
++g_connectedRobotCnt;
m_link = link;
if (g_connectedRobotCnt % 100 == 0) {
LOG_INFO << name() << " <" << localAddr.toIpPort() << "> connect to <" << peerAddr.toIpPort() << "> success, current robot cnt = " << m_robotMgr->m_robotMap.size();
}
// m_link->send("1\r\n");
}
示例2: bindAddress
bool bindAddress(socket_t sockfd, const NetAddress& localaddr)
{
int ret = bind(sockfd, (struct sockaddr *)&localaddr.m_addr, sizeof(localaddr.m_addr));
if(ret == SOCKET_ERROR) {
LOG_SYSTEM_ERR << "bindAddress failed address=<" << localaddr.toIpPort() << ">";
return false;
}
return true;
}
示例3: onDisconnect
void Robot::onDisconnect(Link *link, const NetAddress& localAddr, const NetAddress& peerAddr)
{
/*
if (link->m_isCreateByConnector) {
Robot *robot = m_robotMgr->createRobot();
m_robotMgr->m_wan.connect(peerAddr.toIp(), peerAddr.toPort(), *robot);
}
*/
if (m_robotMgr->m_robotMap.size() - 1 % 100 >= 0) {
LOG_INFO << "robot<" << m_robotId << "> <" << localAddr.toIpPort() << "> to gateserver <" << peerAddr.toIpPort() << "> closed! current robot cnt = " << m_robotMgr->m_robotMap.size() - 1;
}
m_robotMgr->onRobotDisconnect(this);
}