本文整理汇总了C++中ServerSocket::cleanup方法的典型用法代码示例。如果您正苦于以下问题:C++ ServerSocket::cleanup方法的具体用法?C++ ServerSocket::cleanup怎么用?C++ ServerSocket::cleanup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ServerSocket
的用法示例。
在下文中一共展示了ServerSocket::cleanup方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: acceptConnection
//
//RETURNS true if there are any messages in the msg que (msg's will have been just added)
//
bool
SimpleServer::processSockets(int iReady)
{
//check for a new connection
if(FD_ISSET(m_sListen,&m_rset))
{
acceptConnection();
iReady--;
}
//loop through all sockets or until there are no more ready connections
ServerSocket* s;
PacketMessage* pmsg;
for(s=m_listClients.getHead(); s && iReady; s=m_listClients.getNext())
{
try
{
if(FD_ISSET(*s,&m_rset))
{
s->readData(); //reads into a buffer the serv socket has
PacketBuffer* ppacket;
while((ppacket = s->extractPacket()))
{
pmsg = new PacketMessage(s,ppacket);
m_que.add(pmsg);
}
}
if(s)
{
if(FD_ISSET(*s,&m_wset))
s->sendBuffer();
}
}
catch(SocketInstanceException& e)
{
// There was a socket error, this guy should be shut down.
UNUSED_ALWAYS(e);
queClosedMessage(s);
s->cleanup();
m_listClients.removeCurrent(listPREV);
DELETE_NULL(s);
}
catch(ServerSocketException& e)
{
// An invalid packet was detected, this socket should be shut down.
UNUSED_ALWAYS(e);
queClosedMessage(s);
s->cleanup();
m_listClients.removeCurrent(listPREV);
DELETE_NULL(s);
}
}
return !m_que.isEmpty(); //return false if the que is empty instead of isEmpty()'s true
}