AI.1.3 Delete the closed client socket from the socket list:
Code:
BOOL CClientSocketList::Delete(CClientSocket *del)
{
CClientSocket *tmp=Head;
if(!Head)
{
return FALSE;
}
while(tmp!=del&&tmp->Next!=0) tmp=tmp->Next;
if(tmp!=del)
return FALSE;//break;//errors
else
{
if(tmp->Front)
if(tmp->Next)
{
tmp->Front->Next=tmp->Next;
tmp->Next->Front=tmp->Front;
}
else
{
tmp->Front->Next=NULL;
}
else
if(tmp->Next)
{
Head=tmp->Next;
tmp->Next->Front=NULL;
}
else
{
Head=NULL;
}
}
return TRUE;
}
AI.1.4 Create the userInfo table:
Code:
http://www.751com.cn/
CString info;
info.Format("%s",buff);
info=info.Mid(5);
long id ;
CString strId ;
id = ReturnID(); //2.get the new user ID
if(id == -1)
{
strId = "1000" ;
info="#"+strId+"|"+info;
}
else
{
strId.Format("%d",++id);
info="#"+strId+"|"+info;
}
AddUserInfo(info);//3.write new user info into the file
char idChar[100];
CString idStr;
idStr="0x01"+strId;
sprintf(idChar,"%s",idStr);
cs->Send(idChar,100); //4.return the new ID
}
long CClientSocket::ReturnID() //return the last ID in the userInfo table
{
CString fPath = GetCurPath() + ";
CFile aFile;
CFileStatus status;
if( CFile::GetStatus( fPath, status ) )
{
// Open the file without the Create flag
aFile.Open( fPath, CFile::modeReadWrite );
上一页 [1] [2] [3] [4] [5] [6] [7] [8]