本文整理汇总了C++中TcpConnection::getFromIp方法的典型用法代码示例。如果您正苦于以下问题:C++ TcpConnection::getFromIp方法的具体用法?C++ TcpConnection::getFromIp怎么用?C++ TcpConnection::getFromIp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TcpConnection
的用法示例。
在下文中一共展示了TcpConnection::getFromIp方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
bool
ListenerWorker::onUpdateTimer(void* args)
{
UInt32 currTime = TimeUtil::getTimeSec();
if (currTime - mLastSecurityCheckTime >= 300000)
{
mLastSecurityCheckTime = currTime;
for (Set<TcpConnection*>::Iter* iter = mMainConnectionSet.begin(); iter != NULL;)
{
TcpConnection* conn = iter->mValue;
if (conn)
{
if (currTime - conn->getRecvTimeStamp() >=
CLIENT_CONNECTION_SECURITY_CHECK_INTERVAL)
{
LOG_WARN("Connection [%s:%u] was closed for timeout.",
conn->getFromIp().c_str(), conn->getFromPort());
LYNX_DEREGISTER_RECEIVED(conn, this, &ListenerWorker::onMainReceived);
LYNX_DEREGISTER_CONNECT_BROKEN(conn, this, &ListenerWorker::onMainDisconnected);
conn->close();
iter = mMainConnectionSet.erase(iter);
XDELETE(conn);
}
else
{
iter = mMainConnectionSet.next(iter);
}
}
}
for (Set<TcpConnection*>::Iter* iter = mGMConnectionSet.begin(); iter != NULL;)
{
TcpConnection* conn = iter->mValue;
if (conn)
{
if (currTime - conn->getRecvTimeStamp() >=
CLIENT_CONNECTION_SECURITY_CHECK_INTERVAL)
{
LOG_WARN("Connection [%s:%u] was closed for timeout.",
conn->getFromIp().c_str(), conn->getFromPort());
LYNX_DEREGISTER_RECEIVED(conn, this, &ListenerWorker::onGMReceived);
LYNX_DEREGISTER_CONNECT_BROKEN(conn, this, &ListenerWorker::onGMDisconnected);
conn->close();
iter = mGMConnectionSet.erase(iter);
XDELETE(conn);
}
else
{
iter = mGMConnectionSet.next(iter);
}
}
}
}
return true;
}