本文整理汇总了C++中CIOBuffer::GetUserData方法的典型用法代码示例。如果您正苦于以下问题:C++ CIOBuffer::GetUserData方法的具体用法?C++ CIOBuffer::GetUserData怎么用?C++ CIOBuffer::GetUserData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CIOBuffer
的用法示例。
在下文中一共展示了CIOBuffer::GetUserData方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: catch
int CSocketServer::WorkerThread::Run()
{
try
{
while ( true )
{
/*
* Continually loop to service io completion packets
*/
bool closeSocket = false;
DWORD dwIoSize = 0;
Socket *pSocket = 0;
CIOBuffer *pBuffer = 0;
try
{
m_iocp.GetStatus( (PDWORD_PTR)&pSocket, &dwIoSize, (OVERLAPPED **)&pBuffer );
}
catch (const CWin32Exception &e)
{
if ( e.GetError() != ERROR_NETNAME_DELETED &&
e.GetError() != WSA_OPERATION_ABORTED )
{
throw;
}
Output( _T("IOCP error [client connection dropped] - ") +
GetLastErrorMessage( ::WSAGetLastError() ) );
closeSocket = true;
}
if ( !pSocket )
{
/*
* A completion key of 0 is posted to the iocp to request us to shut down...
*/
break;
}
/*
* Call to unqualified virtual function
*/
OnBeginProcessing();
if ( pBuffer )
{
const IO_Operation operation = static_cast<IO_Operation>( pBuffer->GetUserData() );
switch ( operation )
{
case IO_Read_Request:
Read( pSocket, pBuffer );
break;
case IO_Read_Completed :
if ( 0 != dwIoSize )
{
pBuffer->Use( dwIoSize );
//DEBUG_ONLY( Output(_T("RX: ") + ToString(pBuffer) + _T("\n") + DumpData(reinterpret_cast<const BYTE*>( pBuffer->GetWSABUF()->buf), dwIoSize, 40) ) );
/*
* Call to unqualified virtual function
*/
ReadCompleted( pSocket, pBuffer );
}
else
{
/*
* client connection dropped...
*/
Output( _T("ReadCompleted - 0 bytes - client connection dropped") );
closeSocket = true;
}
pSocket->Release();
pBuffer->Release();
break;
case IO_Write_Request :
Write( pSocket, pBuffer );
if ( dwIoSize != 0 )
{
/*
* final write, now shutdown send side of connection
*/
pSocket->Shutdown( SD_SEND );
}
//.........这里部分代码省略.........