SelGate.h
上传用户:szopptop
上传日期:2013-04-23
资源大小:1047k
文件大小:1k
- #ifndef _SELGATE_DEFINE
- #define _SELGATE_DEFINE
- class CSessionInfo
- {
- public:
- SOCKET sock;
- OVERLAPPED Overlapped;
- WSABUF DataBuf;
- CHAR Buffer[DATA_BUFSIZE];
- int bufLen;
- public:
- // ORZ:
- CSessionInfo()
- {
- bufLen = 0;
- }
- int Recv()
- {
- DWORD nRecvBytes = 0, nFlags = 0;
- DataBuf.len = DATA_BUFSIZE - bufLen;
- DataBuf.buf = Buffer + bufLen;
- memset( &Overlapped, 0, sizeof( Overlapped ) );
- return WSARecv( sock, &DataBuf, 1, &nRecvBytes, &nFlags, &Overlapped, 0 );
- }
- bool HasCompletionPacket()
- {
- return memchr( Buffer, '!', bufLen ) ? true : false;
- }
- // recv 滚欺俊辑 肯己等 窍唱狼 菩哦阑 惶酒辰促.
- char * ExtractPacket( char *pPacket )
- {
- int packetLen = (char *) memchr( Buffer, '!', bufLen ) - Buffer + 1;
- memcpy( pPacket, Buffer, packetLen );
- memmove( Buffer, Buffer + packetLen, DATA_BUFSIZE - packetLen );
- bufLen -= packetLen;
- return pPacket + packetLen;
- }
- };
- void InsertLogMsg(UINT nID);
- void InsertLogMsg(LPTSTR lpszMsg);
- #endif //_SELGATE_DEFINE