1 UINT PCClientThread(LPVOID p){ 2 CTCPServerDlg *dlg=(CTCPServerDlg*)AfxGetApp()->GetMainWnd(); 3 SOCKET temp; 4 char buff[1024]; 5 int len=sizeof(SOCKADDR); 6 temp=accept(dlg->m_PCVideoSocket,(sockaddr*)&(dlg->serv),&(len));//接受客户端链接,将此连接分配给一个空闲的客户端socket 7 AfxBeginThread(PCClientThread,0); 8 if (temp==INVALID_SOCKET) //链接出错,重新将此客户端socket赋值为NULL 设置为空闲 9 { 10 return 0; 11 }else{ 12 VIDEO_SOCK_INFO sockInfo;// 13 sockInfo.acceptSock=temp; 14 sprintf(sockInfo.staffId,"%s",""); 15 sockInfo.isBusy=false; 16 sockInfo.videoSock=0; 17 dlg->acceptVideoSockArray.Add(sockInfo); 18 int s=1; 19 if(s!=SOCKET_ERROR) 20 { 21 //接收指令 22 s=recv(temp,buff,1024,0); 23 } 24 } 25 int i=0; 26 while(i<dlg->acceptVideoSockArray.GetSize()) 27 { 28 SOCKET sock=dlg->acceptVideoSockArray[i].acceptSock; 29 if(temp==sock){ 30 dlg->acceptVideoSockArray.RemoveAt(i); 31 break; 32 } 33 i++; 34 } 35 36 return 0; 37 }