【正文】
1 Linux 下 網(wǎng)絡(luò)聊天室的設(shè)計(jì)與實(shí)現(xiàn) 林仁明 計(jì)算機(jī)學(xué)院通信工程專業(yè) 2021 級 指導(dǎo)老師:岳淼 摘要 : 本 系統(tǒng)采用 C/S 結(jié)合的結(jié)構(gòu) ,客戶端與客戶端以及客戶端與服務(wù)器端之間 通過 基于 TCP/IP 協(xié)議 Socket 套接口 傳送消息。服務(wù)器設(shè)計(jì)與實(shí)現(xiàn)過程中 采用了多線程技術(shù),可以在單個程序當(dāng)中同時運(yùn)行多個不 同的線程 執(zhí)行不同的任務(wù)。大大增強(qiáng)了程序?qū)Ψ?wù)器資源的利用。在 Linux 下編寫并調(diào)試服務(wù)器端程序和客戶端程序 ,實(shí)現(xiàn)了客戶、服務(wù)器之間的連接和通信。 可以在單機(jī)上開辟兩個窗口實(shí)現(xiàn)客戶端和服務(wù)器,或者兩臺主機(jī)鏈接分別作為客戶端和服務(wù)器??傮w來說,此設(shè)計(jì)以嵌入式 C 語言為開發(fā)語言,使用網(wǎng)絡(luò)套接字 socket 建立連接, 并運(yùn)行多線程實(shí)現(xiàn)數(shù)據(jù)交換,程序經(jīng) GCC 調(diào)試成功,可以在單機(jī)網(wǎng)絡(luò)中使用。 關(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 embedded C language for the development of language, the use of work sockets 2 socket connection is established and run multithreaded data exchange program GCC debugging can be used in standalone work. Keywords: TCP / IP。 the linux。 the socke 目錄 摘要 ................................................................................................................................. 1 Abstract ............................................................................................................................ 1 第一章:緒論 ................................................................................................................... 3 什么是網(wǎng)絡(luò)編程 .................................................................................................. 3 優(yōu)點(diǎn) ................................................................................................................... 3 第二章 linux網(wǎng)絡(luò)聊天室設(shè)計(jì)思想 .................................................................................. 4 功能分析 ............................................................................................................ 4 總體設(shè)計(jì) ............................................................................................................ 4 第三章 linux網(wǎng)絡(luò)聊天室工具概述 .................................................................................. 5 GCC ................................................................................................................... 5 GCC 簡介 ................................................................................................... 5 GCC 執(zhí)行過程 ............................................................................................ 5 GCC 基本使用方法 ..................................................................................... 5 GNU Makefile........................................................................................................ 6 Makefile簡介 ........................................................................................... 6 Makefile 規(guī)則 ............................................................................................. 7 GDB 調(diào)試 ............................................................................................................ 7 用 gdb 調(diào)試 GCC 程序 ............................................................................... 7 第四章 關(guān)鍵技術(shù)分析 ...................................................................................................... 8 linux 線程間通信 .................................................................................................. 8 .................................................................................................... 8 .................................................................................................... 8 線程數(shù)據(jù)處理 ............................................................................................ 9 基于 linux 的 socket 網(wǎng)絡(luò)編程 ............................................................................... 9 端口和套接口 ............................................................................................ 9 套接字和套接口地址結(jié) 構(gòu) ........................................................................ 10 基本轉(zhuǎn)換函數(shù) .......................................................................................... 11 socket()和 bind()函數(shù) ....................................................................... 12 listen()和 accept()函數(shù) ..................................................................... 12 socket 中 TCP 的三次握手建立連接詳解 ..................................................... 13 、 socket 中 TCP 的四次握手釋放連接詳解 ......................................................... 14 第五章 linux下 socket編程實(shí)現(xiàn)過程 ........................................................................... 15 3 聊天室 socket 編譯鏈接過程 .............................................................................. 15 具體操作 .......................................................................................................... 16 參考文獻(xiàn): .................................................................................................................... 18 附錄 ............................................................................................................................... 18 附錄 A: ............................................................................... 18 附錄 B: ................................................................................. 23 附錄 C: ................................................................................................. 26 附錄 D: ..............................................