本文整理汇总了C++中TcpServer::AddConnect方法的典型用法代码示例。如果您正苦于以下问题:C++ TcpServer::AddConnect方法的具体用法?C++ TcpServer::AddConnect怎么用?C++ TcpServer::AddConnect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TcpServer
的用法示例。
在下文中一共展示了TcpServer::AddConnect方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RecvParse
void* TcpServer::RecvParse(void* pData)
{
TcpServer* pthis = NULL;
mio2_t m = NULL;
LPMESSAGE_DATA pMsg = NULL;
int iLen = 0;
if (pData) {
m = ((c2s_t)pData)->mio2;
pthis = (TcpServer*)(((c2s_t)pData)->pvoid);
}
if (!pthis || !m) {
gvLog(LOG_ERR_SYS, "(TcpServer::RecvParse) receive pool start fail by error param");
return NULL;
}
RecvParser* pRecvParser = new RecvParser();
if (!pRecvParser) return NULL;
LPMESSAGE_DATA pErrMsgData = NULL;
while (pthis->IsRunning()) {
pMsg = g_MsgListRecv->Get_Msg();
if (pMsg) {
gvLog(LOG_MSG, "(TcpServer::RecvParse) entering receive parser... iFd:%d", pMsg->iFd);
iLen = pRecvParser->ParserData(pMsg);
gvLog(LOG_MSG, "(TcpServer::RecvParse) MSG: iLen:%d iFd:%d", iLen, pMsg->iFd);
if (iLen > 0) {
//put into data parser
pthis->AddConnect();
pMsg = MatchPacketHandler::GetInstance()->Handling(pMsg, pErrMsgData);
if (NULL != pMsg){
g_MsgListData->Put_Msg(pMsg);
}
else if (NULL != pErrMsgData){
pErrMsgData->bSendAndClose = true;
g_MsgListSnd->Put_Msg(pErrMsgData);
}
else {
if (NULL != pMsg) {
gvLog(LOG_MSG, "(TcpServer::RecvParse) MSG: MatchPacketHandler() iFd:%d", pMsg->iFd);
}
}
} else {
if (iLen == 0) {
//maybe (errno == EWOULDBLOCK || errno == EINTR || errno == EAGAIN)
gvLog(LOG_MSG, "(TcpServer::RecvParse) (iLen == 0) iFd:%d", pMsg->iFd);
} else {
gvLog(LOG_MSG, "(TcpServer::RecvParse) mio2_close iFd:%d", pMsg->iFd);
mio2_close(m, pMsg->iFd);
}
gvLog(LOG_MSG, "(TcpServer::RecvParse) MSG: fail iFd:%d pMsg:%p", pMsg->iFd, pMsg);
PutIdleMsgBuff(pMsg);
}
gvLog(LOG_MSG, "(TcpServer::RecvParse) left receive parser... pMsg:%p", pMsg);
}
usleep(1);
}
}