【正文】
畢業(yè)設(shè)計 ( 論文 ) 簡易代理服務(wù)器的設(shè)計 論文作者姓名: 申請學位專業(yè): 申請學位類別: 指導(dǎo)教師姓名(職稱): 論文提交日期: 簡易代理服務(wù)器的設(shè)計 摘 要 代理服務(wù)器是介于瀏覽器和 Web 服務(wù)器之間的一臺服務(wù)器,它的功能 是代理網(wǎng)絡(luò)用戶去取得網(wǎng)絡(luò)信息。它的工作原理是,接收客戶機的數(shù)據(jù)連接請求,并將請求傳給 Web 服務(wù)器;再從 Web 服務(wù)器接收返回的數(shù)據(jù),最后把數(shù)據(jù)傳給客戶端顯示。本論文講述的是關(guān)于一個簡單的代理服務(wù)器的實現(xiàn),在實現(xiàn)中采用客戶機 /服務(wù)器結(jié)構(gòu)模型開發(fā)應(yīng) 用程序,基于一般的訪問瀏覽速度慢、效率底、安全功能不強等原因,將以簡單、合理、有效為原則;為了方便分析和設(shè)計,系統(tǒng)設(shè)計中設(shè)置不同的狀態(tài)量用于標識客戶機、代理服務(wù)器及服務(wù)器間的聯(lián)結(jié)狀態(tài)。在保證系統(tǒng)基本功能的同時,使用多線程機制使得代理系統(tǒng)有更好的延續(xù)性。此代理系統(tǒng)具有簡單,易用,網(wǎng)絡(luò)化等優(yōu)點,能夠完成一般的 HTTP 訪問代理服務(wù) 。 關(guān)鍵詞 : 客戶機 /服務(wù)器結(jié)構(gòu);多線程; 套接字 ;代理服務(wù)器 The Design of Simple Proxy Server Abstract The proxy server is a server which situates between the browser and a Web server. It’s principle of work is, it receives the connection request from the client, and hands down the requested to the Web server, then receives data which is returned from the Web server., finally hands it down the data to the client. In the realization, it adopts Client/Server structural model to develop application. Because of browse speed slow, low efficient and not safe enough, it takes simple, reasonable and effective as the principle. In the system design, it sets different states to identify client, proxy server and the connective state between servers. When the system39。s basic function are guaranteed, it use the multithreading to enable the proxy server to have a better continuous feature. This proxy system has the merit such as simple, easy to use and so on, and it can plete the proxy of general HTTP visit. Key words: Client / Server architecture; Multithreading; Socket; Proxy Server 目 錄 論文總頁數(shù): 20頁 1 引言 .......................................................................................................................... 1 課題背景 ............................................................................................................ 1 本課題研究的意義 ............................................................................................... 1 本課題的研究方法 ............................................................................................... 1 2 理論基礎(chǔ) ................................................................................................................... 2 代理服務(wù)器 ......................................................................................................... 2 目前的代理服務(wù)技術(shù) ............................................................................................ 3 SOCKET 面向連接的編程模型 ................................................................................ 4 WINSOCK庫 ......................................................................................................... 5 winsock 的尋址方式 ...................................................................................... 5 字節(jié)順序 ..................................................................................................... 6 系統(tǒng)基本套接字調(diào)用 ............................................................................................ 6 創(chuàng)建和關(guān)閉套接字- socket()和 closesocket() .................................................... 6 指定本地地址- bind() ................................................................................... 6 設(shè)置監(jiān)聽狀態(tài) listen() .................................................................................... 6 建立套接字連接- connect()和 accept() ............................................................ 6 收發(fā)數(shù)據(jù) send()和 recv() ................................................................................ 7 3 設(shè) 計方案 ................................................................................................................... 7 基本函數(shù)設(shè)計 ...................................................................................................... 7 多線程流程 ......................................................................................................... 8 4 服務(wù)器的實現(xiàn) ............................................................................................................. 8 環(huán)境創(chuàng)建 ............................................................................................................ 8 功能實現(xiàn) ............................................................................................................ 9 數(shù)據(jù)變量定義 ............................................................................................... 9 啟動代理服務(wù)器 ......................................................................................... 10 請求處理過程 ............................................................................................. 11 請求響應(yīng) ................................................................................................... 13 關(guān)閉服務(wù)器 ................................................................................................ 15 控制主函數(shù) ................................................................................................ 15 5 測試結(jié)果 ................................................................................................................. 15 結(jié) 論 ........................................................................................................................ 17 參考文獻 ........................................................................................................................ 18 致 謝 ........................................................................................................................ 19 聲 明 ........................................................................................................................ 20 第 1 頁 共 20頁 1 引言 課題背景 普通的因特網(wǎng)訪問是一 種典型的客戶機與服務(wù)器結(jié)構(gòu),而代理服務(wù)器將運行于客戶機與服務(wù)器之間,它作為 Inter/Intra 上常用的一種服務(wù)器,通常配置在 Intra 連接 Inter 的出口處,主要實現(xiàn)代理傳輸服務(wù)??梢赃@樣認為,代理是雙向的。即對于內(nèi)部網(wǎng)上的用戶來說,代理服務(wù)器可看作是一個外部網(wǎng)的代理;對于外部網(wǎng)絡(luò)來說,代理服務(wù)器可以看作一個要訪問外部網(wǎng)的客戶。正是由于代理服務(wù)器的這種控制方式,可以使用它提高客戶訪問外網(wǎng)的效率、節(jié)省網(wǎng)絡(luò)帶寬,增強網(wǎng)絡(luò)安全性以及減少網(wǎng)絡(luò)投資等。代理服務(wù)器從提出到現(xiàn)在,不斷的經(jīng)歷著內(nèi)容 更進和技術(shù)的革新,各種代理服務(wù)器產(chǎn)品更是層出不窮。不難看出,代理服務(wù)器在我們信息時代的生活中扮演著越來越重要的作用。 本課