本文整理汇总了C++中CTcpSocket::OnClear方法的典型用法代码示例。如果您正苦于以下问题:C++ CTcpSocket::OnClear方法的具体用法?C++ CTcpSocket::OnClear怎么用?C++ CTcpSocket::OnClear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CTcpSocket
的用法示例。
在下文中一共展示了CTcpSocket::OnClear方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RunOnce
void CIOServer::RunOnce()
{
if (m_io == NULL || m_cb == NULL)
{
LCF("Can't Run Once. server not initialize or initialize false.");
return;
}
DWORD dwTranceCount = 0;
ULONG_PTR uComKey = NULL;
LPOVERLAPPED pOverlapped = NULL;
BOOL bRet = GetQueuedCompletionStatus(m_io, &dwTranceCount, &uComKey, &pOverlapped, 1000/*INFINITE*/);
//检查定时器超时状态
{
unsigned int curTime = GetTimeMillisecond();
if (curTime - m_lasttime > 1000)
{
m_lasttime = curTime;
m_cb->OnTimer();
}
if (!bRet && !pOverlapped)
{
//TIMEOUT
return;
}
}
//! 检查自定义通知
if (uComKey == PCK_ACCEPT_CLOSE)
{
CTcpAccept *pp = (CTcpAccept *) (ULONG_PTR)pOverlapped;
pp->OnClear();
return;
}
else if (uComKey == PCK_SOCKET_CLOSE)
{
CTcpSocket *pp = (CTcpSocket*) (ULONG_PTR)pOverlapped;
pp->OnClear();
return;
}
else if (uComKey == PCK_USER_DATA)
{
m_cb->OnPost((void *)pOverlapped);
return;
}
//! 处理来自网络的通知
unsigned char type = ((tagReqHandle*)pOverlapped)->_type;
switch (type)
{
case tagReqHandle::HANDLE_ACCEPT:
{
CTcpAccept *pKey = (CTcpAccept *) uComKey;
pKey->OnIOCPMessage(bRet);
}
break;
case tagReqHandle::HANDLE_RECV:
case tagReqHandle::HANDLE_SEND:
case tagReqHandle::HANDLE_CONNECT:
{
CTcpSocket *pKey = (CTcpSocket *) uComKey;
pKey->OnIOCPMessage(bRet, dwTranceCount, type);
}
break;
default:
LCE("GetQueuedCompletionStatus undefined type=" << type);
}
}