毕业论文论文范文课程设计实践报告法律论文英语论文教学论文医学论文农学论文艺术论文行政论文管理论文计算机安全
您现在的位置: 毕业论文 >> 英语论文 >> 正文

VC++即时通讯系统设计英文论文 第8页

更新时间:2010-6-17:  来源:毕业论文
即时通讯系统设计英文论文
AI.1.1  Create socket and listen to the client:
Code:
void CHHSeverApp::OnServerStart()
{
 // TODO: Add your command handler code here
 if(!AfxSocketInit())
 {
  AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
 }
 m_listenSocket.Create(6767);
 m_listenSocket.Listen();
}
AI.1.2  Add the connected client socket to the socket list:
Code:
BOOL CClientSocketList::Add(CClientSocket *add,CString ID)
{
 add->m_ID=ID;
 CClientSocket *tmp=Head;
 if(!Head)
 {
  Head=add;
  return true;
 }
 while(tmp->Next)tmp=tmp->Next;
 tmp->Next=add;
 add->Front=tmp;
 return true;
}

 


 
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.youerw.com/
  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] 

VC++即时通讯系统设计英文论文 第8页下载如图片无法显示或论文不完整,请联系qq752018766
设为首页 | 联系站长 | 友情链接 | 网站地图 |

copyright©youerw.com 优文论文网 严禁转载
如果本毕业论文网损害了您的利益或者侵犯了您的权利,请及时联系,我们一定会及时改正。