本文整理汇总了C++中CEvent::delFdEvent方法的典型用法代码示例。如果您正苦于以下问题:C++ CEvent::delFdEvent方法的具体用法?C++ CEvent::delFdEvent怎么用?C++ CEvent::delFdEvent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CEvent
的用法示例。
在下文中一共展示了CEvent::delFdEvent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onRead
void onRead(int iFd,void *pData)
{
cout<<"onRead "<<iFd<<endl;
SESession *pSession=new SESession();
pSession->iSize=::read(iFd,pSession->szBuf,MAXLINE);
if (pSession->iSize > 0)
{
pSession->szBuf[pSession->iSize]='\0';
cout<<pSession->szBuf<<endl;
oCEvent.addFdEvent(iFd,CEvent::EV_WRITE,onWrite,pSession);
}
else if(pSession->iSize == 0)
{
delete pSession;
oCEvent.delFdEvent(iFd,CEvent::EV_WRITE|CEvent::EV_READ);
lce::close(iFd);
cout<<"onClose "<<iFd<<endl;
}
else
{
delete pSession;
oCEvent.delFdEvent(iFd,CEvent::EV_WRITE|CEvent::EV_READ);
lce::close(iFd);
}
}
示例2: onWrite
void onWrite(int iFd,void *pData)
{
cout<<"onWrite "<<iFd<<endl;
SESession *pSession = (SESession*)pData;
::send(iFd,pSession->szBuf,pSession->iSize,0);
oCEvent.delFdEvent(iFd,CEvent::EV_WRITE);
//::close(iFd);
delete pSession;
}
示例3: onConnect
void onConnect(int iFd,void *pData)
{
oCEvent.delFdEvent(iFd,CEvent::EV_READ|CEvent::EV_WRITE);
int err = 0;
socklen_t errlen = sizeof(err);
if(getsockopt(iFd, SOL_SOCKET, SO_ERROR, &err, &errlen) < 0)
{
cout<<"fail1"<<endl;
return;
}
if(err == 0)
{
cout<<"onConnect"<<endl;
}
else
{
cout<<"onConnectFail"<<endl;
}
oCEvent.addFdEvent(iFd,CEvent::EV_READ,onRead,NULL);
cout<<"onConnect"<<endl;
}