本文整理汇总了C++中CIOBuffer::SetUserData方法的典型用法代码示例。如果您正苦于以下问题:C++ CIOBuffer::SetUserData方法的具体用法?C++ CIOBuffer::SetUserData怎么用?C++ CIOBuffer::SetUserData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CIOBuffer
的用法示例。
在下文中一共展示了CIOBuffer::SetUserData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PostAbortiveClose
void CSocketServer::PostAbortiveClose( Socket *pSocket )
{
CIOBuffer *pBuffer = Allocate();
pBuffer->SetUserData( IO_Close );
pSocket->AddRef();
m_iocp.PostStatus( (ULONG_PTR)pSocket, 0, pBuffer );
}
示例2: Write
void CSocketServer::Write(
Socket *pSocket,
const char *pData,
size_t dataLength,
bool thenShutdown)
{
if ( !pSocket || !pData || dataLength <= 0 )
{
return;
}
/*
* Post a write request to the iocp so that the actual socket write gets performed by
* one of our IO threads...
*/
CIOBuffer *pBuffer = Allocate();
/*
* Call to unqualified virtual function
*/
#ifdef NETWORK_DEBUG
//{
PreWrite( pSocket, pBuffer, pData, dataLength + PACK_HEADER_LEN + sizeof(BYTE) );
//}
#else
//{
PreWrite( pSocket, pBuffer, pData, dataLength );
//}
#endif // NETWORK_DEBUG
pBuffer->AddData( pData, dataLength );
#ifdef NETWORK_DEBUG
//{
const BYTE *pPackData = pBuffer->GetBuffer();
PACK_HEADER ph = {0};
memcpy( (BYTE *)&ph, pPackData, PACK_HEADER_LEN );
pBuffer->AddData( (BYTE *)&ph, PACK_HEADER_LEN );
pBuffer->AddData( 0xAA );
//}
#endif // NETWORK_DEBUG
pBuffer->SetUserData( IO_Write_Request );
pSocket->AddRef();
m_iocp.PostStatus( (ULONG_PTR)pSocket, thenShutdown, pBuffer );
}