// //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 }