【正文】
d do it, said Mrs. March, smiling as if satisfied. You shall all go and help me, and when we e back we will have bread and milk for breakfast, and make it up at dinnertime. They were soon ready, and the procession set out. Fortunately it was early, and they went through back streets, so few people saw them, and no one laughed at the queer party. A poor, bare, miserable room it was, with broken windows, no fire, ragged bedclothes, a sick mother, wailing baby, and a group of pale, hungry children cuddled under one old quilt, trying to keep warm. How the big eyes stared and the blue lips smiled as the girls went in. Ach, mein Gott! It is good angels e to us! said the poor woman, crying for joy. Funny angels in hoods and mittens, said Jo, and set them to laughing. In a few minutes it really did seem as if kind spirits had been at wor k there. Hannah, who had carried wood, made a fire, and stopped up the broken panes with old hats and her own cloa k. Mrs. March gave the mother tea and gruel, and forted her with promises of help, while she dressed the little baby as tenderly as if it had been her own. T he girls meantime spread the table, se t the children round the fire, and fed them like so many hungry birds, laughing, talking, and trying to understand the funny broken English. Das ist gut! Die Engel kinder! cried the poor things as they ate and warmed their purple hands at the fortable blaze. T he girls had never been c alled angel children before, and thought it very agreeable, especially Jo, who had been considered a `Sancho39。s Mother. Hide the basket, quick! cried Jo, as a door slammed and steps sounded in the hall. Amy came in hastily, and looked rather abashed when she saw her sisters all waiting for her. Where have you been, and what are you hiding behind you? asked Meg, surprised to see, by her hood and cloak, that lazy Amy had been out so early. Don39。s gone and put `Mother39。 關(guān)于學位論文使用權(quán)和研究成果知識產(chǎn)權(quán)的說明: 本人完全了解成都信 息工程學院有關(guān)保管使用學位論文的規(guī)定,其中包括: ( 1)學校有權(quán)保管并向有關(guān)部門遞交學位論文的原件與復印件。 [4] 汪翔 ,袁輝 .Visual C++ 實踐與提高網(wǎng)絡(luò)編程篇 [M].武漢:中國鐵路出版社 ,2021。 結(jié) 論 通過對本次課題的研究,運 用套接字的編程完成了網(wǎng)絡(luò)間的通信。x39。注意,程序中多次用到 WSACleanup(),這是因為 應(yīng)用程序或 DLL 在使用 Windows Sockets 服務(wù)之前必須要進行一次成功的WSAStartup()調(diào)用 .當它完成了 Windows Sockets 的使用后 ,應(yīng)用程序或 DLL 必須調(diào)用 WSACleanup()將其從 Windows Sockets 的實現(xiàn)中注銷 ,并且該實現(xiàn)釋放為應(yīng)用程序或 DLL 分配的任何資源 . 控制主函數(shù) 由于 控制臺應(yīng)用程序本身不具 備窗口應(yīng)用程序中良好的界面操作性,因此主函數(shù)內(nèi)只能對程序界面操作進行 簡單的控制。 closesocket(pParpPairsoc_ClitoPro)。 } Len=retval。 pParpPairStateProtoSerClosed=TRUE。 memset(amp。 SOCKET conn_socket。 ifdef _DEBUG Buffer[Len]=0。 closesocket()。 p=strstr(buf,HTTP)。 } } 當客戶端關(guān)閉連接時,這時接收的數(shù)據(jù)為 0,也需要將此時 socket 狀態(tài)進行調(diào)整: printf(Client Close connection\n)。 =FALSE。 當客戶端有請求發(fā)到代理服務(wù)器時,偵聽 中的 Proxy 就會調(diào)用函數(shù) accept來響應(yīng)對主機的連接請求,同時 Proxy 會啟動另一個偵聽線程,以準備接收客戶端的下一個請求。 字節(jié)順序轉(zhuǎn)換函數(shù) 用于將 將 u_short類型變量 port從 主機字節(jié)順序轉(zhuǎn)化到TCP/IP 網(wǎng)絡(luò)字節(jié)順序 (即: host to nework short)。為了將本地地址附加到所創(chuàng)建的套接字上以便能夠有效地標識套接字,我們需用 bind 函數(shù)來完成這一步: SOCKET listen_socket。運用結(jié)構(gòu)體 Str_BasalSocket,里面定義客戶端到代理服務(wù)器及代理服務(wù)器到 Server 間套接字兩個,以及客戶端、代理服務(wù)器和 Server 間的連接狀態(tài)變量兩個; Str_ProParam 結(jié)構(gòu)體定義 Server 地址變量,指向結(jié)構(gòu)體 Str_BasalSocket 的指針,聯(lián)結(jié) Server 主機的端口變量和代理服務(wù)器到Server 連接狀態(tài)的句柄變量,這個結(jié)構(gòu)體是用來代理服務(wù)器與 Server 主機交換信息 。有幾種方法可以實現(xiàn)這兩個目標,但每一種方法都有各自的代價。這需要設(shè)計一個函數(shù)來解析地址,設(shè)計過程中用 ReceiveInformation 函數(shù)來實現(xiàn)。 收發(fā)數(shù)據(jù) send()和 recv() 對流套接字來說,一般使用 send 和 recv 函數(shù)來收發(fā)數(shù)據(jù)。綁定到套接字上的本地名稱包括主機地址、協(xié)議號和端口號 3部分。當不使用此套接字時,應(yīng)該用 closesocket函數(shù)關(guān)閉套接字,如果沒有錯誤發(fā)生,函數(shù)返回 0,否則返回 SOCKET_ERROR。 應(yīng)用程序可以使用 i_addr函數(shù)將一個小數(shù)點分隔的 十進制 IP地址字符串轉(zhuǎn)化成由 32 位二進制數(shù)表示的 IP 地址。 TCP/IP使用地址和端口號來指定一個地址,但是其它協(xié)議也許采用不同的形式。當服務(wù)器端的 accept 函數(shù)返回后, connect 函數(shù)也返回。 Socket 面向連接的編程模型 代理服務(wù)器既然是雙向的客戶機 /服務(wù)器模型,它工作時通常有一個公共的規(guī)則需要遵守,通信雙方需要共同遵守這個規(guī)則才能保證通信的有效進行,如需要量傳輸大量語音信息時須采用一種無須建立連接的傳輸方式,在這種方式下,數(shù)據(jù)可以以較快的速度傳輸。 ICS 方式也稱之為 Inter 轉(zhuǎn)換連接。代理服務(wù)器和目的地址通訊時,源 IP 是代理服務(wù)器的 IP,當 然 外部的數(shù)據(jù)也是一樣的 。還有平日里我們最為常用的顯 IP版 ,在 “ 發(fā)送消息 ” 窗口中,可以查看對方的 IP 及解析出的地理 位置。 節(jié)省 IP開銷:前面所講,所有用戶對外只占用一個 IP,所以不必租用過多的 IP 地址,降低網(wǎng)絡(luò)的維護成本。 2 理論基礎(chǔ) 代理服務(wù)器 代理服務(wù)器 的 英文全稱是 Proxy Server,其功能就是代理網(wǎng)絡(luò)用戶去取得網(wǎng)絡(luò)信息。而且 從保證安全性的角度出發(fā), 我們也 很有 必要開發(fā)一個自己的 代理 服務(wù)器。正是由于代理服務(wù)器的這種控制方式,可以使用它提高客戶訪問外網(wǎng)的效率、節(jié)省網(wǎng)絡(luò)帶寬,增強網(wǎng)絡(luò)安全性以及減少網(wǎng)絡(luò)投資等。它的工作原理是,接收客戶機的數(shù)據(jù)連接請求,并將請求傳給 Web 服務(wù)器;再從 Web 服務(wù)器接收返回的數(shù)據(jù),最后把數(shù)據(jù)傳給客戶端顯示。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