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

正文內(nèi)容

嵌入式操作系統(tǒng)課程設(shè)計報告-資料下載頁

2024-09-02 12:29本頁面

【導(dǎo)讀】青春沒有借口流淚,我們承諾永不后退!第二周、周5:驗收,提交設(shè)計報告,評定成績。為了加強(qiáng)對Linux系統(tǒng)下的編程的各種知識點的整合與靈活運用,讓我們更加熟悉Linux. 下的編程操作,我們選擇了Linux下網(wǎng)絡(luò)聊天工具作為課設(shè)題目。本系統(tǒng)主要功能在于實現(xiàn)多個客戶端與服務(wù)器端之間的信息傳遞與文件傳輸功能。要實現(xiàn)4大聊天室功能:注冊與登錄系統(tǒng),公聊,私聊,文件傳輸。網(wǎng)絡(luò)編程并使用TCP實現(xiàn)簡單聊天程序。最終做成了簡單的在LINUX下的聊天工具。

  

【正文】 { char buf[1024]。 int n。 struct msq msg。 fd = open(,O_RDONLY|O_CREAT)。 signal(SIGINT,handlequit)。 if(fd0) { printf(打開文件失敗 \n)。 return 1。 } lseek(fd,0,SEEK_END)。 if((qid = msgget(2222,IPC_CREAT|0666)) == 1) { printf(創(chuàng)建消息隊列失敗 \n)。 close(fd)。 return 1。 } while(1) { if(msgrcv(qid,amp。msg,sizeof(msg),0,0) 0) { printf(讀取消息對列失敗 \n 客戶端可能已經(jīng)退出本程序?qū)⒁黄鹜顺?\n)。 close(fd)。 return 1。 } memset(buf,0,sizeof(buf))。 n = read(fd,buf,1024)。 write(STDOUT_FILENO,buf,n)。 } close(fd)。 return 0。 } /************/ include LinkList CreateLinkList() { LinkList L = (LinkList)malloc(sizeof(LNode))。 Lnext = NULL。 return L。 } void deletelist(LinkList L ,datatype e) { int i=0。 LinkList s,p。 嵌入式 操作系統(tǒng)課程 設(shè)計 27 p = L。 while ( (strcmp(p,) != 0) amp。amp。 pnext != NULL) { s=p。 p = pnext。 } if (pnext == NULL amp。amp。 (strcmp(p,) != 0)) { return。 } else { snext = pnext。 free(p)。 } } void insertend(LinkList L,datatype e) { int i=0。 LinkList s,p。 p = L。 while(pnext != NULL) { p = pnext。 i++。 } s = (LinkList)malloc(sizeof(LNode))。 sdata =e。 snext = pnext 。 pnext =s。 } void DisplayList(LinkList L) { L=Lnext。 int i = 1。 while (L != NULL) { printf(%d. %s \n,i,L)。 L = Lnext。 i++。 } } /* void main() { LinkList L。 datatype res=0。 L=CreateLinkList()。 printf(aaaaa\n)。 DisplayList(L)。 printf(aaaaa\n)。 printf(\n)。 insertend(L,500)。 printf(\n)。 insertend(L,300)。 printf(\n)。 insertend(L,200)。 DisplayList(L)。 printf(\n)。 deletelist(L,200)。 DisplayList(L)。 printf(刪除第 2 個位置的 %d 后 ,res)。 printf(\n)。 }*/ /************/ include include include include include sys/ include include i/ include typedef struct _clientinf { 嵌入式 操作系統(tǒng)課程 設(shè)計 28 char name[10]。 struct sockaddr_in addr_in。 int decr。 pthread_t pid。 }clientinf。 typedef clientinf datatype。 typedef struct _LNode { datatype data。 struct _LNode * next。 }LNode,*LinkList。 extern LinkList CreateLinkList(void)。 extern void deletelist(LinkList L ,datatype e)。 extern void insertend(LinkList L,datatype e)。 extern void DisplayList(LinkList L)。 /************/ include include include include include sys/ include include i/ include include arpa/ include include include define MAXLEN 1024 /* struct message { char flag[15]。 char name[10]。 int size。 char msg[MAXLEN]。 }。 */ LinkList clientlink。 void handlesignal() { int choose。 char name[10]。 while(1) { printf( 除指定客戶端, 器 , \n)。 scanf(%d,amp。choose)。 while(choose 1 || choose 3) { printf(請輸入上面提示的選項 :\n)。 scanf(%d,amp。choose)。 } gets(name)。 if(choose == 1) { printf(請輸入你踢出去的客戶端名字 :\n)。 gets(name)。 if(strcmp(name,) == 0) continue。 LinkList L,s。 L = clientlink。 L=Lnext。 s = L。 while((strcmp(L,name) != 0) amp。amp。 Lnext != NULL) { s = L。 L = Lnext。 } //printf(1%s\n,L)。 if(Lnext == NULL amp。amp。 (strcmp(L,name) != 0)) { printf(該客戶端不存在 \n)。 } else { close(L)。 嵌入式 操作系統(tǒng)課程 設(shè)計 29 pthread_cancel(L)。 snext = Lnext。 free(L)。 } printf(3\n)。 } else if(choose == 2) { /* LinkList L,s。 L = clientlinknext。 while(L != NULL) { s = Lnext。 close(L)。 free(L)。 L = s。 } free(clientlink)。 */ 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) 嵌入式 操作系統(tǒng)課程 設(shè)計 30 { 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。 }
點擊復(fù)制文檔內(nèi)容
環(huán)評公示相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1