linux聊天室程序如何實現

代碼:

#ifndef?_i_h ? #define?_i_h ? #include?<math.h> #include?<stdio.h> #include?<sys> #include?<arpa> #include?<netinet> #include?<unistd.h> #include?<sys> #include?<sys> #include?<fcntl.h> #include?<stdlib.h> #include?<errno.h> #include?<string.h> #include?<inttypes.h> #include?<time.h> #include?<sys>? #include?<net> #include?<signal.h> #include?<ncurses.h> #include?<math.h> ? #define?sevr_ip???"127.0.0.1" #define?sevr_port??8081 #define?cntnt_len??150 #define?msg_len???sizeof(struct?msg) #define?addr_len??sizeof(struct?sockaddr) #define?usr_len???sizeof(struct?user) #define?prt_len???8 #define?hstr_len??sizeof(struct?chat_history) ? /*?declare?global?variables?*/ int?mainfd;/*?used?as?chat?histroy?file?handle*/ int?sockfd;/*?used?as?socket?local?handle?*/ int?count; struct?sockaddr_in?server; ? /*?msg?is?used?for?communicating?message?*/ struct?msg { ??int?flag;?/*?flag?meaning:1,ordinary;?2,log?msg;?3,reg?msg,?other,file*/ ??int?id_from; ??int?id_to; ??char?content[cntnt_len]; ??char?append[10];? }; ? /*?user?is?used?information?list?*/ struct?user { ??int?id; ??char?name[10]; ??char?password[10]; ??char?*p_chatlog; ??struct?sockaddr?user_addr;? }; /*?chat_history?used?for?reading?chat?history?*/ struct?chat_history { ??char?content[cntnt_len]; ??char?time[25]; ??int?to; ??int?from; ??int?count; }; ? /*?i_functions?below?is?funtions?needed?by?both?client?and?sever?*/ extern?int?i_saveto_chat(struct?msg?*pmsg); ? int?i_clean_stdin?() { ??while?('n'?==?getchar()) ??{ ????continue; ??} ? ??return(0); } ? int?i_print(char?*pmsg,?int?size) { ??int?i?=?1; ? ??for?(i;?iid_from; ??hstr.to?=?pmsg-&gt;id_to; ??strncpy(hstr.content,?pmsg-&gt;content,?cntnt_len); ??strncpy(hstr.time,?i_get_time(),?25); ? ??i_lseek(mainfd,?0,?seek_end); ? ??i_write(mainfd,?&amp;hstr,?hstr_len); ? ??return(0); } ? int?i_print_history(int?len,?int?i) { ??struct?chat_history?chat_reader; ??int?j; ??int?position; ??? ??bzero(&amp;chat_reader,?hstr_len); ??if?(i?!=?0) ??{ ????position?=?len*i*hstr_len; ????i_lseek(mainfd,?position,?seek_end); ??} ??else ??{ ????position?=?len*i*hstr_len; ? ????i_lseek(mainfd,?hstr_len,?seek_set); ??} ????? ??for?(j?=?1;?j?<p><strong>代碼二:</strong></p> <pre class="brush:bash;">#include?"i.h" ? int?user_list_fd; ? /*?start:initialization?*/ int?init() { ??i_init(); ? ??user_list_fd?=?i_open("./user_list",?o_rdwr|o_creat); ? ??struct?user?usr; ??/*?init?the?user?list?file's?fist?user?to?0*/ ??memset((struct?user*)&amp;usr,?'

国产精品久久久久久久久|
99久久成人18免费网站|
久久精品亚洲AV久久久无码|
亚洲中文字幕无码一久久区
|
粉嫩小泬无遮挡久久久久久|
97久久久精品综合88久久|
亚洲乱亚洲乱淫久久|
热久久视久久精品18|
久久超乳爆乳中文字幕|
久久久久久噜噜精品免费直播|
影音先锋女人AV鲁色资源网久久|
精品综合久久久久久97超人|
亚洲精品tv久久久久久久久久|
国产精品久久久久久搜索|
无码人妻久久一区二区三区免费丨|
国产精品久久久久一区二区三区|
777午夜精品久久av蜜臀
|
久久青青草原亚洲av无码|
久久精品夜夜夜夜夜久久|
久久久久av无码免费网|
久久国产免费|
97精品伊人久久久大香线蕉|
五月丁香综合激情六月久久|
中文字幕无码久久久|
99久久精品免费看国产免费|
2022年国产精品久久久久|
中文字幕无码精品亚洲资源网久久
|
久久国产高清字幕中文|
亚洲人成伊人成综合网久久久
|
看全色黄大色大片免费久久久|
色综合色天天久久婷婷基地|
2021久久国自产拍精品|
国产成人精品白浆久久69|
久久久久国产精品熟女影院
|
性欧美大战久久久久久久|
久久精品成人免费国产片小草|
国产高潮国产高潮久久久91
|
久久婷婷久久一区二区三区
|
久久精品国产亚洲AV香蕉|
波多野结衣久久一区二区|
国产免费久久精品99re丫y|