freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內容

linux基于socket下的簡單聊天室-資料下載頁

2025-06-19 14:13本頁面
  

【正文】 lse { close(L)。 pthread_cancel(L)。 snext = Lnext。 free(L)。 } printf(3\n)。 } else if(choose == 2) { return。 } else if(choose == 3) { DisplayList(clientlink)。 } }}void handleclient (clientinf *client){ clientinf clientNode = *client。 int nread。 struct message a。 LinkList transfileNode。 char buf[MAXLEN],str[MAXLEN]。 while(1) { nread= recv(,amp。a,sizeof(a),0)。 if(nread == 0) { strcpy(,sermsg)。 printf(客戶端%s退出\n,)。 deletelist(clientlink ,clientNode)。 LinkList L。 L = clientlink。 L=Lnext。 sprintf(buf,客戶端%s退出\n,)。 while(L != NULL) { send(L,buf,strlen(buf)+1,0)。 L = Lnext。 } return。 } if(strcmp(,login) == 0) { int i。 i = login_check(amp。a)。 if(i == 0) { strcpy(buf,登錄成功!)。 strcpy(,)。 insertend(clientlink,clientNode)。 send(,buf,strlen(buf)+1,0)。 } else { strcpy(buf,登錄失敗!)。 send(,buf,strlen(buf)+1,0)。 } continue。 } else if(strcmp(,reg) == 0) { int i。 i = reg_check(amp。a)。 if(i == 0) { strcpy(buf,注冊成功!)。 strcpy(,)。 send(,buf,strlen(buf)+1,0)。 } continue。 } else if (strcmp(,all) == 0) { if (strcmp(,) != 0) { LinkList L。 L = clientlink。 L=Lnext。 strcpy(,)。 while(L != NULL) { send(L,amp。a,sizeof(struct message),0)。 L = Lnext。 } } continue。 } else if(strcmp(,view) == 0) { LinkList L。 int i = 1。 L = clientlink。 L=Lnext。 memset(buf,0,strlen(buf))。 while(L != NULL) { memset(str,0,strlen(str))。 sprintf(str,%d. %s\n,i,L)。 strcat(buf,str)。 // send(,str,strlen(str)+1,0)。 L = Lnext。 i++。 } strcpy(,)。 strcpy(,buf)。 send(,amp。a,sizeof(struct message),0)。 continue。 } else if(strcmp(,trans) == 0) { LinkList L。 L = clientlink。 L=Lnext。 while(L != NULL) { if (strcmp(L,) == 0) { break。 } L = Lnext。 } if(L == NULL) { strcpy(,noexist)。 send(,amp。a,sizeof(struct message),0)。 } else { transfileNode = L。 strcpy(,)。 send(L,amp。a,sizeof(struct message),0)。 } continue。 } else if(strcmp(,transf) == 0) { send(transfileNode,amp。a,sizeof(struct message),0)。 continue。 } else { LinkList L。 L = clientlink。 L=Lnext。 //sprintf(buf,%s:%s\n,)。 strcpy(,)。 while(L != NULL) { if (strcmp(L,) == 0) { //send(L,buf,strlen(buf)+1,0)。 send(L,amp。a,sizeof(struct message),0)。 break。 } L = Lnext。 } continue。 } }}void handleaccept(int *serverfd){ socklen_t client_len。 int sockfd = *serverfd。 clientinf clientNode。 struct sockaddr_in client_addr。 while(1) { client_len =sizeof(struct sockaddr_in)。 if(( = accept(sockfd,(struct sockaddr *)amp。client_addr,amp。client_len)) == 1) { printf(接收連接失敗\n)。 } else { printf(與%s:%d連接建立成功\n,inet_ntoa(),ntohs())。 = client_addr。 pthread_create(amp。,NULL,(void *)handleclient,(void *)amp。clientNode)。 } }}int main(int argc ,char *argv[]){ struct sockaddr_in server_addr,client_addr。 int sockfd,connectfd,port,nread。 pthread_t pid。 char buf[MAXLEN]。 char str[MAXLEN]。 if(argc != 2) { printf(請輸入端口\n)。 exit(1)。 } if((sockfd= socket(AF_INET,SOCK_STREAM,0)) == 1) { printf(創(chuàng)建socket失敗\n)。 exit(1)。 } clientlink = CreateLinkList()。 clientlink = sockfd。 port = atoi(argv[1])。 bzero(amp。server_addr,sizeof(struct sockaddr_in))。 = AF_INET。 = htonl(INADDR_ANY)。 = htons(port)。 if(bind(sockfd,(struct sockaddr *)amp。server_addr,sizeof(struct sockaddr)) == 1) { printf(綁定端口失敗,端口可能被占用\n)。 exit(2)。 } if(listen(sockfd,20) == 1) { printf(監(jiān)聽端口失敗\n)。 exit(3)。 } printf(正在監(jiān)聽中...\n)。 pthread_create(amp。pid,NULL,(void *)handleaccept,(void *)amp。sockfd)。 handlesignal()。 return 0。 }教材及參考文獻 UNIX程序設計教程. 趙克佳等編著. 清華大學出版社. 2001年4月操作系統(tǒng)原理、技術與編程(Linux篇). 蔣靜,徐志偉著. 2004年1月Linux應用實例與技巧 姚繼鋒等著 機械工業(yè)出版社 2001年9月深入理解Linux內核 陳莉君等譯 中國電力出版社 2001年10月Linux網(wǎng)絡編程技術 天雨創(chuàng)作室編著 人民郵電出版社 2001年1
點擊復制文檔內容
環(huán)評公示相關推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1