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

正文內(nèi)容

畢業(yè)設(shè)計(jì)-基于linux下網(wǎng)絡(luò)聊天室的設(shè)計(jì)與實(shí)現(xiàn)(留存版)

2025-01-30 02:13上一頁面

下一頁面
  

【正文】 = addr_size。: strncpy(server_ip, optarg, 15)。 sleep(3)。ts)。readfds)) 26 { memset(buffer_r, 39。 if(buf[0]==39。 } //printf(\n)。 pointersocketfd=sockfd。 free(del_p)。, 3, 0)。 wc = send(headsocketfd, buffer, BUFF_SIZE, 0)。 while(*p_addr) { *p++=*p_addr++。 return head。 buf[1]=39。 // strcat(buffer,))。039。amp。 } 附錄 D: include USER_LIST creat_pointer(void) { USER_LIST head。 } printf(\n)。readfds)) break。 //0 wc = send(sockfd, buffer_w, BUFF_SIZE, 0)。 FD_SET(sockfd, amp。server_addr, addrlen) == 1) { if(count ++ 3) { close(sockfd)。: 24 server_port = atoi(optarg)。attr)。 next_p=next_pnext。 USER_LIST next_p=NULL。 if (bind(sockfd, (struct sockaddr *)amp。readfds)) }//select return value 0 }//while (RUNNING) close(newfd)。 } else { /**************Server read*****************/ if (FD_ISSET(newfd, amp。 FD_ZERO(amp。 其 makefile 指令為: CC := gcc CFLAGS += w g O O2 O3 o RM := rm rf *~ LIBS := lpthread all: $(CC) $(CFLAGS) multithread_tcp_server $(LIBS) $(CC) $(CFLAGS) multithread_tcp_client $(LIBS) clean: $(RM) 執(zhí)行編譯命令為: 編譯沒有錯(cuò)誤則會(huì)生成可執(zhí)行文件。例如 Web 服務(wù)器在 80 號(hào)端口監(jiān)聽,當(dāng)有客戶向80號(hào)端口發(fā)出連接請求時(shí) (如 圖 3- 2 所示) ,服務(wù)器將接受請求且由服務(wù)器進(jìn)程派生出子進(jìn)程和新的套接口(由 accept()的返回值指向)來與客戶連接并通信 (如 圖 所示) 。 原型: int bind(int sockfd, struct sockaddr *my_addr ,int addrlen). 功能:使套接口與 IP地址和端口號(hào)綁定。sin_port 和 sin_sddr 應(yīng)該轉(zhuǎn)換成為網(wǎng)絡(luò)字節(jié)優(yōu)先順序; struct in_addr 其定義如下: struct in_addr{ unsigned long s_addr。應(yīng)用程序中使用套接字來調(diào)用套接口,套接字可認(rèn)為是指向套接口的指針,就像文件描述符是指向文件的指針一樣。 所需頭文件 include 函數(shù)原型 void pthread_exit(void *retval) 函數(shù)傳入值 retval:pthread_exit()調(diào)用 者線程的返回值,可由其他函數(shù)如pthread_join 來檢索獲取 等待線程退出并釋放資源 pthread_join() 所需頭文件 include 函數(shù)原型 int pthread_join ((pthread_t th, void **thread_return)) 函數(shù)傳入值 th:等待線程的標(biāo)識(shí)符 9 thread_return:用戶定義的指針,用來存儲(chǔ)被等待線程的返回值(不為 NULL時(shí)) 函數(shù)返回值 成功: 0 出錯(cuò): 1 線程數(shù)據(jù)處理 線程數(shù)據(jù)處理和進(jìn)程相比,線程的最大優(yōu)點(diǎn)之一是數(shù)據(jù)的共享性,各個(gè)進(jìn)程共享父進(jìn)程處沿襲的數(shù)據(jù)段,可以方便的獲得、修改數(shù)據(jù)。 list 執(zhí)行一行源代碼但不進(jìn)入函數(shù)內(nèi)部??梢?, makefile 都成為了一種在工程方面的編譯方法。 GCC 基本使用方法 在使用 Gcc 編譯器的時(shí)候,我們必須給出一系列必要的調(diào)用參數(shù)和文件名稱。首先要存儲(chǔ)客戶的個(gè)人資料,相當(dāng)于注冊。 優(yōu)點(diǎn) Linux 作為一個(gè)開源的操作系統(tǒng) Linux 的許多特性有利于網(wǎng)絡(luò)編程。 可以在單機(jī)上開辟兩個(gè)窗口實(shí)現(xiàn)客戶端和服務(wù)器,或者兩臺(tái)主機(jī)鏈接分別作為客戶端和服務(wù)器。它是一組計(jì)算機(jī)通信協(xié)議族具有開放式互聯(lián)環(huán)境很容易實(shí)現(xiàn)各種局域網(wǎng)和廣域網(wǎng)的集成式互聯(lián)。之后也變得可處理 Fortran、 Pascal、 ObjectiveC、Java, 以及 Ada 與其他語言。 Idirname,將 dirname 所指出的目錄加入到程序頭文件目錄列表中,是在預(yù)編譯過程中使用的參數(shù)。 調(diào)試信息包含你程序里的每個(gè)變量的類型和在可執(zhí)行文件里的地址映射以及源代碼的行號(hào)。 gdb 支持很多與 UNIX shell 程序一樣的命令編輯特征。 端口:標(biāo)識(shí)傳輸層與應(yīng)用程序的數(shù)據(jù)接口(服務(wù)訪問點(diǎn) SAP),每個(gè)端口有一個(gè) 16位的標(biāo)識(shí)符,稱為端口號(hào) 。 IPV4 套接口地址結(jié)構(gòu) struct sockaddr_in 的定義如下: struct sockaddr_in{ short int sin_family。 假設(shè)有一個(gè) struct sockaddr_in ina,并且 IP 是 ,想把它存儲(chǔ)到 ina,可以使用 i_addr()。 功能: socket 與某一端口捆綁以后,就需要監(jiān)聽該端口,以便到達(dá)的服務(wù)請求加以處理。 (3) 使用 bind 函數(shù)綁定端口及其 IP地址。 int maxfd = newfd。 if (ret == 1) { if (errno == EINTR) { goto select_label。 close(newfd)。i, sizeof(i))。 pthread_attr_init(amp。 } else { close(sockfd)。 send_list( head)。\039。 bzero(amp。 while(RUNNING) { select_label: 25 maxfd = ((maxfd sockfd) ? maxfd : sockfd)。 case 0://select time out //fprintf(stderr, server time out\n)。 err_sys(client recv) } else if(rc == 0) { close(sockfd)。 buf++。amp。 if(num==0) { printf(free err\n)。 if(head==NULL) return 0。039。 } int send_list(USER_LIST head) { int wc。39。 } while(pi!=NULL) { buf[1]=(char)pinumber。 char count=0。039。 } int forward(USER_LIST head,char *buf,int newfd) { int wc。 } if(headnumber==num) { if(headnext!=NULL) del_p=headnext。amp。 while(*buf!=39。readfds)。 default: /**************Client write****************/ if (FD_ISSET(STDIN_FILENO, amp。 = 0。 = AF_INET。 if(argc != 5) { fprintf(stderr, Usage:%s p server_port i server_ip\n, argv[0])。 fprintf(stderr, Master thread[%u] created a new thread failurefully\n, 23 pthread_self())。 } if(head==NULL) { next_p=creat_pointer()。 pthread_attr_setdetachstate(amp。 bzero(amp。readfds)。 if(delet!=NULL) head=delet。 char buffer_r[BUFF_SIZE]。 2 發(fā)送請求 (1) 獲取主機(jī)信息 (2) 初始化 socket 端口 (3)利用 connect 函數(shù)講自己的 IP 地址等信息發(fā)送到主機(jī),等待主機(jī)接受信息。 原型: int accept(int sockfd, void *addr,int *addrlen )。 (注: i_addr()返回的地方已經(jīng)是網(wǎng)絡(luò)字節(jié)順序了 ) 也可以把一個(gè) struct in_addr 代表的 IP地址打印出來(按照 數(shù)字 .數(shù)字 .數(shù)字 .數(shù)字的格式)如 printf(“%s”,i_ntoa() )。 /* 端口號(hào) */ struct in_addr sin_addr。網(wǎng)絡(luò)應(yīng)用程序之間通過套接口來實(shí)現(xiàn)通信。 8 第 四 章 關(guān)鍵技術(shù)分析 linux 線程 間通信 線程是一個(gè)進(jìn)程內(nèi)的基本調(diào)度單位,也可以稱為輕量級進(jìn)程。在編譯時(shí)用 g 選項(xiàng)打開調(diào)試選項(xiàng)。對于 A類,預(yù)處理程序 cpp 在系統(tǒng)預(yù)設(shè)包含文件目錄 (如 /usr/include)中搜尋相應(yīng)的文件,而B類,預(yù)處理程序在目標(biāo)文件的文件夾內(nèi)搜索相應(yīng)文件。 命令 gcc 首先調(diào)用 cpp 進(jìn)行預(yù)處理,在預(yù)處理過程中, 對源代碼文件中的文件包含 (include)、預(yù)編譯語句 (如 宏 定義 define 等 )進(jìn)行分析。 第二章 linux 網(wǎng)絡(luò)聊天室 設(shè)計(jì)思想 功能分析 本系統(tǒng)是想在 linux 系統(tǒng)下實(shí)現(xiàn)一個(gè)聊天室系統(tǒng),只要有服務(wù)器和客戶端。 關(guān)鍵字: TCP/IP; linux; socket Design and Implementation of Inter chat rooms under Linux Linren Ming Of Computer Science, Communication Engineering 2021 Instructor: Yue Miao Abstract: This system uses a bination of C / S structure, between the client and the client and customer client and serverside through the TCP / IP protocolbased Socket sets of interfaces to deliver messages. Used in server design and implementation of multithreading technology, in a single program which is running a number of different threads to perform different tasks. Greatly enhanced the program on the use of server resources. To write and debug serverside program and client program under Linux, the connection between the client, server and munications. Two windows can be opened up on a standalone client and server, or the two hosts links, respectively, as the client and server. Overall, this design emb
點(diǎn)擊復(fù)制文檔內(nèi)容
公司管理相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號(hào)-1