【正文】
,而不對單個記錄進行操作,可操作記錄集,所有 SQL 語句接受集合作為輸入,返回集合作為輸出。 TCP/IP 協(xié)議 (1)IP、 TCP 協(xié)議的特點: TCP/IP( Transmission Control Protocol/Inter Protocol)是傳輸控制協(xié)議 /網(wǎng)際協(xié)議的縮寫 , TCP/IP 是當(dāng)今網(wǎng)絡(luò)互聯(lián)的核心協(xié)議。 統(tǒng)一分配網(wǎng)絡(luò)地址,使得每個 TCP/IP 設(shè)備在網(wǎng)絡(luò)中都具有唯一的 IP地址。在數(shù)據(jù)傳輸過程中,各種服務(wù)器不斷的檢測分配給他的端口,一邊發(fā)現(xiàn)要求和他通信的客戶端。服務(wù)器也通過它的本地端口連接一個 socket,通過讀寫和客戶端通信。如果有客戶端連接請求,則在數(shù)組中選擇一個空 Socket,將客戶端地址賦給這個 Socket。注冊流程如下:用戶提出注冊請求,客 戶端響應(yīng),彈出注冊信息對話框,用戶輸入相關(guān)信息并提交,客戶端首先進行合法檢查,確定無誤后將數(shù)據(jù)信息發(fā)送給服務(wù)器端。 ServerSocket sendserversocket = new ServerSocket(7777)。 } } } 23 注冊代碼: package 。 import 。 private JButton loginButton = null。 private Socket socketaccept。 } public LoginRegisterFrame() { super()。 25 } private void initialize() //初始化 { (getXLocation(),getYLocation())。 userLabel = new JLabel()。 (getLoginButton(), null)。 } 用戶登錄模塊的實現(xiàn) 本界面需要填寫的有兩個,一個是用戶名,另一個是用戶密碼。 (登錄 )。 PrintWriter pw = new PrintWriter(os,true)。 //true\0UserUserName\0UserPassword\0UserName\0UserEmail\0UserPower\0UserState\0UserIP if(b[0].equals(true)) { (b[1])。 new MainChatFrame(socketaccept,socketsend,userinfo)。 (new (){ public void actionPerformed( e) //登陸界面點注冊按鈕 { (客戶端 RegisterRegisteractionPerformed())。 new RegisterFrame(socketaccept,socketsend,xloc,yloc)。 } return passwordTextField。 33 圖 53 聊天系統(tǒng)聊天界面 核心代碼: private JButton getSendButton() //聊天界面 按 發(fā)送按鈕 { if (sendButton == null) { sendButton = new JButton()。 for(int i=0。 } ()。 }。 } return sendButton。i++) { operation = operation+\0+ob[i]。 (發(fā) 送 )。服務(wù)器接收到請求后確定聊天方式。 } return resigerButton。 str = (17)。 } } catch (IOException e2) { ()。 (b[3])。 InputStream is = ()。 String username = ()。如果成功,便打開主程序窗口。 26 (userLabel, null)。 (用戶名 )。 (getLoginResigerPanel())。 } public LoginRegisterFrame(Socket socketaccept,Socket socketsend,int x,int y) { super()。 private int xLocation = 200。 private JLabel userLabel = null。 import 。 import 。 while(true) { Socket acceptsocket = ()。 注冊流程圖如下: 基于 C/S 模式的聊天系統(tǒng) 通信(聊天) 文件傳輸 注冊 登陸 私聊 群聊 查看好友資料 查找好友 添加好友 查找群 添加群 創(chuàng)建好友分組 共享文件 查看共享文件并下載 21 注冊界面如下圖 51所示。 客戶端工作流程 客戶端程序相對簡單,只需要建立一個 Socket 與服務(wù)器端連接,成功后通過這個Socket 來發(fā)送和接收數(shù)據(jù)就可以了。 數(shù)據(jù)通信:利用虛擬連接通道傳送數(shù)據(jù)信息進行通道。也就是說網(wǎng)絡(luò)上兩個或兩個以上雙工方式通信的進程之間總有一個連接,這個連接的端點成為套接字,套接字是在比較低的層次上通信的。 (2)TCP/IP 協(xié)議進行傳輸數(shù)據(jù)傳輸?shù)倪^程: 應(yīng)用程序為了傳輸數(shù)據(jù)會調(diào)用 TCP,將數(shù)據(jù)和對應(yīng)的參數(shù)傳給 TCP,將 TCP 數(shù)據(jù)包封裝在 IP 包內(nèi),通過網(wǎng)絡(luò)送給目的 TCP。 IP 協(xié)議的作用:第一,它是網(wǎng)絡(luò)層的協(xié)議,提供互聯(lián)網(wǎng)上數(shù)據(jù)傳輸?shù)慕y(tǒng)一格式。 統(tǒng)一的語言: SQL 可用于所有用戶的 db 活動模型,包括系統(tǒng)管理員、數(shù)據(jù)庫管理員、 應(yīng)用程序員、決策支持系統(tǒng)人員及許多其它類型的終端用戶。 SQL語句通常用于完成一些數(shù)據(jù)庫的操作任務(wù),比如在數(shù)據(jù)庫中更新數(shù)據(jù),或者從數(shù)據(jù)庫中檢索數(shù)據(jù)。空間并共同構(gòu)成一個大的進程。根據(jù)用戶要求和模型行為的結(jié)果,控制器選擇一個視作為對用戶請求的應(yīng)答。一個模型能為多個視圖提供數(shù)據(jù),因此提高了代碼的可重用性。它允許程序動態(tài)地裝入運行過程中所需要的類,這是 C++語言進行面向?qū)ο蟪绦蛟O(shè)計所無法實現(xiàn)的。 JAVA 編譯器產(chǎn)生的目標(biāo)代碼 (JCode) 是針對一種并不存在的 CPUJAVA 虛擬機 (JAVA Virtual Machine),而不是某一實際的 CPU。 Java 提供 Null 指針檢 測數(shù)組邊界、檢測異常出口、字節(jié)代碼校驗。 此外 Java 提供了豐富的類庫。 MySQL 是一個真正的多用戶、多線程 SQL 數(shù)據(jù)庫服務(wù)器,它有較好的數(shù)據(jù)承載能力,一個環(huán)境有超過 40 個數(shù)據(jù)庫,包含 10,000 個表,其中 500 多個表超過 7百萬行,總數(shù)據(jù)大約有 100GB 的數(shù)據(jù)庫系統(tǒng)可以很好的被 MySQL 所支持,而 MySQL 本身不會像Oracle 那樣對系統(tǒng)及硬盤空間有很高的要求 。更有甚者稱數(shù)據(jù)庫是“一個數(shù)據(jù)倉庫”。 信息提示窗口的“確認(rèn)”及“取消”按鈕需要分別映射鍵盤按鍵“ Enter”和“ ESC”。 表格數(shù)據(jù)列表 字符型數(shù)據(jù)保持左對齊,數(shù)值型右對齊(方便閱讀對比),并根據(jù)字段要求,統(tǒng)一顯示小數(shù)位位數(shù)。 保持語言的一致性,如“確定”對應(yīng)“取消” ,“是”對應(yīng)“否”。 鼠標(biāo)手勢 可點擊的按鈕、鏈接需要切換鼠標(biāo)手勢至手型; 保持功能及內(nèi)容描述一 致 避免同一功能描述使用多個詞匯,如編輯和修改,新增和增加,刪除和清除混用等。目前不能支持文件夾下載,當(dāng)看到一個文件夾以后,可以雙擊該文件夾并查看文件夾里面的文件。如果未找到,則彈出一個信息提示框。用戶在執(zhí)行添加群操作以后,客 戶端分將一個這個動作的信息發(fā)送給服務(wù)器端(主要是 FromClientlisten)。 4)群聊 群聊,就是多人一起聊天。 功能需求 本系統(tǒng)要實現(xiàn)的功能如下: 1)注冊 服務(wù)器收到用戶的注冊請求,便開始接受客戶傳遞的信息,諸如客戶的呢稱,性別,籍貫,個人資料等,接受完畢后,便通過 JDBCODBC與后臺數(shù)據(jù)庫連接,然后向數(shù)據(jù)庫添加記錄,如果成功,便向客戶返回其號碼。另外采用C/S 模式的原因是 C/S 模式的優(yōu)點是能充分發(fā)揮客戶端 PC 的處理能力,很多工作可以在客戶端處理后再提交給服務(wù)器。 2 研究的目的及意義 現(xiàn)在,企業(yè)、機關(guān)、學(xué)校紛紛建立起自己的局域網(wǎng)。 2021 年 6 月 ,行業(yè)的主導(dǎo)服務(wù)商騰訊在香港成功上市。因此開發(fā)網(wǎng)絡(luò)聊天是相當(dāng)有必要,通過聊天系統(tǒng),不僅可以提高訪問量,同時可以留著訪客,更重要的是讓訪客透過聊天系統(tǒng)實時的互相交流。 I 【 摘 要 】 隨著互聯(lián)網(wǎng)的快速發(fā)展,網(wǎng)絡(luò)聊天已經(jīng)成為人們?nèi)粘=涣鳒贤ǖ牟豢苫蛉钡姆绞剑苁苋藗兊那嗖A。s Daily munication, is very popular with the people . At the same time also appeared a lot of very good chat tools at home and abroad, is widely used in it have Tencent 、 Skype and so on. This system is mainly based on the JAVA language and C/S mode of development. The server is established through the Socket, the server can read and deliver the information which client side sends, and can renovate the users tabulation. With the LAN correspondence mechanism principle, through inheriting the Thread kind to establish the multithreading directly. In the development, it uses the elementary theory knowledge which the puter work programme for example, TCP/IP agreement, Client/Server pattern, work programming design method and so on. In the work programming, it realizes reading and transmission of the information, that is,information flows realize the information exchange, introduce information flow analysis for realizing a system, in which contains some basic software engineering methods. After analyzes these situations, this system takes Eclipse as the basic development environment and piles in java language. first, it will establish the system application prototype in a short time. then, for the initial prototype system, it needs constantly revised and improved, until a viable system. 【 Keywords】 LAN Chat Socket JAVA III 目 錄 第一章 緒論 ............................................................................................................................. 1 課題來源 .................................