haitao:
void CMoniServer::SendToAll(const string s)
[阅读: 741] 2005-02-04 07:27:29
void CMoniServer::SendToAll(const string s)
{
if( m_socketList.size() <= 0 )
return;
//commlogStr(loglevel0,"SendAllMoni[");
list<CTcpSocket* >::iterator p;
list<CTcpSocket* >::iterator i=m_socketList.end();
string t=s+"\r\n";
//char buf[100];
for( i-- ; ; )
{
p = i;
if( i!=m_socketList.begin() )
i--;
try
{
if( *p==NULL )
{
commlogStr(loglevel4,"A MoniClientInList is NULL!");
//(*p)->Close();
m_socketList.remove(*p);
continue;
}
if( (*p)->GetHandle()<=0 )
{
commlogStr(loglevel4,"A MoniClientHandleInList is NULL!");
(*p)->Close();
m_socketList.remove(*p);
continue;
}
/*
if( (*p)->ReceiveEx(buf,90)!=0 )
{
commlogStr(loglevel4,"A MoniClientInList is disconnected!");
(*p)->Close();
m_socketList.remove(*p);
continue;
}
*/
(*p)->SendEx( t.c_str(),t.size() );
}
catch (CSocketException& ex)
{
commlogIntMsg(loglevel3,"MoniClientException",ex.GetCode(),ex.GetMsg());
if( *p!=NULL )
(*p)->Close();
m_socketList.remove(*p);
}
if( i==m_socketList.begin() )
break;
}
//commlogStr(loglevel0,"SendAllMoni]");
}