本文整理汇总了C++中CTcpSocket::HandleNetworkEvent方法的典型用法代码示例。如果您正苦于以下问题:C++ CTcpSocket::HandleNetworkEvent方法的具体用法?C++ CTcpSocket::HandleNetworkEvent怎么用?C++ CTcpSocket::HandleNetworkEvent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CTcpSocket
的用法示例。
在下文中一共展示了CTcpSocket::HandleNetworkEvent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ThreadFunc
DWORD WINAPI CTcpSocket::ThreadFunc(LPVOID pParam)
{
DWORD dwWaitStatus; // holds return value of the wait
CTcpSocket * p = (CTcpSocket *)pParam; // connection-specific data
while (TRUE)
{
// Wait for an event
dwWaitStatus = WSAWaitForMultipleEvents(3, p->m_eventArray,
FALSE, // fWaitAll
WSA_INFINITE, // dwTimeout
FALSE); // fAlertable
switch (dwWaitStatus)
{
case WSA_WAIT_FAILED: // A fatal error
OutputDebugString(_T("WSAWaitForMultipleEvents() failed\n"));
break;
case WSA_WAIT_EVENT_0: // The hNetEvent has been signaled.
if (p->HandleNetworkEvent())
{
continue;
}
break;
case WSA_WAIT_EVENT_0+1: // The hOutputEvent has been signaled.
if (p->HandleOutputEvent())
{
continue;
}
break;
case WSA_WAIT_EVENT_0+2: // Quit time;
OutputDebugString(_T("Hangup by myself\n"));
break;
default:
OutputDebugString(_T("Unknown error in WSAWaitForMultipleEvents()\n"));
break;
} // switch (dwWaitStatus)
// Break out of the while loop.
break;
} // while (1)
// Thread is ending because the connection was closed or an error occurred
p->CleanUp();
return 0;
}