




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
1、畢業(yè)設(shè)計(論文)外文文獻翻譯(2008屆)譯文一: 譯文二: Client Server Programming with Winsock學(xué)生姓名 學(xué) 號 0403040211系 別 信息與電子系專業(yè)班級 計算機科學(xué)與技術(shù)0402指導(dǎo)教師完成日期 2007年11月26日Introduction to TCP/IP IntroductionAuthor Catalyst DevelopmentCatalyst Development is a recognized leader in Internet component software whose award-winning products
2、 are used by thousands of corporate, government and independent developers around the world.IntroductionWith the acceptance of TCP/IP as a standard platform-independent network protocol, and the explosive growth of the Internet, the Windows Sockets API (application program interface) has emerged as
3、the standard for network programming in the Windows environment. This document will introduce the basic concepts behind Windows Sockets programming and get you started with your first application created with SocketWrench.There are two general approaches that you can take when creating a program tha
4、t uses Windows Sockets. One is to code directly against the API. The other is to use a component which provides a higher-level interface to the library by setting properties and responding to events. This can provide a more "natural" programming interface, and it allows you to avoid much o
5、f the error-prone drudgery commonly associated with sockets programming. By including the control in a project, setting some properties and responding to events, you can quickly and easily write an Internet-enabled application. SocketWrench provides a comprehensive interface to the Windows Sockets l
6、ibrary and will be used to build a simple client-server application in the next section of this document. Before we get started with the control, however, we'll cover the basic terminology and concepts behind sockets programming in general.Transmission Control Protocol (TCP)When two computers wi
7、sh to exchange information over a network, there are several components that must be in place before the data can actually be sent and received. Of course, the physical hardware must exist, which is typically either a network interface card (NIC) or a serial communications port for dial-up networkin
8、g connections. Beyond this physical connection, however, computers also need to use a protocol which defines the parameters of the communication between them. In short, a protocol defines the "rules of the road" that each computer must follow so that all of the systems in the network can e
9、xchange data. One of the most popular protocols in use today is TCP/IP, which stands for Transmission Control Protocol/InternetProtocol.When a system sends data over the network using the Internet Protocol, it is sent in discrete units called datagrams, also commonly referred to as packets. A datagr
10、am consists of a header followed by application-defined data. The header contains the addressing information which is used to deliver the datagram to it's destination, much like an envelope is used to address and contain postal mail. And like postal mail, there is no guarantee that a datagram wi
11、ll actually arrive at it's destination. In fact, datagrams may be lost, duplicated or delivered out of order during their travels over the network. Needless to say, this kind of unreliability can cause a lot of problems for software developers. What's really needed is a reliable, straight-fo
12、rward way to exchange data without having to worry about lost packets or jumbled data.To fill this need, the Transmission Control Protocol (TCP) was developed. Built on top of IP, TCP offers a reliable, full-duplex byte stream which may be read and written to in a fashion similar to reading and writ
13、ing a file. The advantages to this are obvious: the application programmer doesn't need to write code to handle dropped or out-of-order datagrams, and instead can focus on the application itself. And because the data is presented as a stream of bytes, existing code can be easily adopted and modi
14、fied to use TCP.TCP is known as a connection-oriented protocol. In other words, before two programs can begin to exchange data they must establish a "connection" with each other. This is done with a three-way handshake in which both sides exchange packets and establish the initial packet s
15、equence numbers (the sequence number is important because, as mentioned above, datagrams can arrive out of order; this number is used to ensure that data is received in the order that it was sent). When establishing a connection, one program must assume the role of the client, and the other the serv
16、er. The client is responsible for initiating the connection, while the server's responsibility is to wait, listen and respond to incoming connections. Once the connection has been established, both sides may send and receive data until the connection is closed.User Datagram ProtocolUnlike TCP, t
17、he User Datagram Protocol (UDP) does not present data as a stream of bytes, nor does it require that you establish a connection with another program in order to exchange information. Data is exchanged in discrete units called datagrams, which are similar to IP datagrams. In fact, the only features t
18、hat UDP offers over raw IP datagrams are port numbers and an optional checksum.UDP is sometimes referred to as an unreliable protocol because when a program sends a UDP datagram over the network, there is no way for it to know that it actually arrived at it's destination. This means that the sen
19、der and receiver must typically implement their own application protocol on top of UDP. Much of the work that TCP does transparently (such as generating checksums, acknowledging the receipt of packets, retransmitting lost packets and so on) must be performed by the application itself.With the limita
20、tions of UDP, you might wonder why it's used at all. UDP has the advantage over TCP in two critical areas: speed and packet overhead. Because TCP is a reliable protocol, it goes through great lengths to insure that data arrives at it's destination intact, and as a result it exchanges a fairl
21、y high number of packets over the network. UDP doesn't have this overhead, and is considerably faster than TCP. In those situations where speed is paramount, or the number of packets sent over the network must be kept to a minimum, UDP is the solution.譯文如下:TCP/IP入門介紹作者 Catalyst DevelopmentCataly
22、st Development是全球公認的領(lǐng)先的互聯(lián)網(wǎng)軟件之一,其屢獲殊榮的產(chǎn)品已廣泛為世界各地成千上萬的企業(yè)、政府和獨立開發(fā)商所使用。緒論隨著TCP/IP作為一種獨立網(wǎng)絡(luò)協(xié)議標準平臺逐漸的被認可,以及互聯(lián)網(wǎng)的激增,在Windows環(huán)境下成為網(wǎng)絡(luò)程序設(shè)計標準的Windows Sockets API (應(yīng)用程序結(jié)口)已經(jīng)步入舞臺。在Windows Sockets編程之后,本文將介紹基本概念并且使用SocketWrench來實現(xiàn)你的第一個應(yīng)用程序。的內(nèi)容當(dāng)在利用Windows Sockets創(chuàng)建一個程序時,有兩個基本途徑。其中一個就是使用API函數(shù)編寫代碼。另外一種方式是通過設(shè)置屬性和響應(yīng)事件來使用
23、所提供的更高層次的接口的組件。它提供了一種更加適當(dāng)?shù)木幊探涌?,使用sockets編程可以避免許多易錯點。在工程部件里包含了這個控件,設(shè)置它的屬性和響應(yīng)它的事件你可以更加迅速而容易的實現(xiàn)網(wǎng)絡(luò)程序的應(yīng)用。socketwrench提供了比較全面的Windows Sockets類庫,并且在文章中的下一部分會被用來建立一個簡單的客戶機-服務(wù)器應(yīng)用。在開始利用該控件編程之前,我們先來學(xué)習(xí)一下通常sockets編程中基本術(shù)語和概念。傳輸控制協(xié)議當(dāng)兩臺電腦之間想通過網(wǎng)絡(luò)交換信息,在真正傳輸和接收數(shù)據(jù)之前,有幾個組成部分是必須的。當(dāng)然,物理硬件必須存在,像典型的網(wǎng)絡(luò)接口卡(網(wǎng)卡)或一個撥號網(wǎng)絡(luò)連接的串行通信端口
24、。盡管如此,在這些物理連接之外,計算機之間同樣也需要定義一些參數(shù)傳遞的協(xié)議。總之,一個協(xié)議定義了“信息通信的規(guī)則”,網(wǎng)絡(luò)中的每臺計算機必須遵循以便使所有的系統(tǒng)可以進行數(shù)據(jù)交換。在當(dāng)今最流行的協(xié)議就是TCP/IP,也即傳輸控制協(xié)議。當(dāng)一個系統(tǒng)通過互聯(lián)網(wǎng)協(xié)議發(fā)送數(shù)據(jù)時,所發(fā)送的不連續(xù)的單位即所謂的數(shù)據(jù)報,也被稱為信息包。一個數(shù)據(jù)報是有報頭和數(shù)據(jù)組成。報頭包含了數(shù)據(jù)報要傳遞的目的地址的信息,就像一個信封,是用來書寫地址、郵件處理。像郵件一樣,不能保證數(shù)據(jù)報就能到達它的目的地。事實上,數(shù)據(jù)報在網(wǎng)絡(luò)傳輸過程中也可能會出現(xiàn)丟失、重復(fù)或無序現(xiàn)象。不用說,這種不可靠性,可能會給軟件開發(fā)人員造成很多問題。那怎么
25、樣才可以實現(xiàn)可靠的、直接的交換數(shù)據(jù),而不出現(xiàn)信息報丟失或者無序的現(xiàn)象。傳輸控制協(xié)議(TCP)的發(fā)展就是為了滿足這個需求。建立在IP基礎(chǔ)上,TCP提供了一個可靠的、全雙工的字節(jié)流可讀可寫類似于對文件的讀寫操作。它的優(yōu)點是顯而易見的:程序員并不需要編寫代碼來處理丟失或無序的數(shù)據(jù)報,而是可以專注于應(yīng)用程序本身。因為數(shù)據(jù)是作為一個字節(jié)流來保存的,使用TCP可以更加容易的修改和使用現(xiàn)有的代碼。眾所周知,TCP是面向連接的協(xié)議。在換句話說,在兩個程序開始進行數(shù)據(jù)交換之前,他們必須建立一個連接 。采用三次握手在雙方交換信息包并且建立初始的序號(序號是非常重要的,因為正如上文所述,數(shù)據(jù)可能出現(xiàn)無序現(xiàn)象,序號可
26、以用來保證數(shù)據(jù)報發(fā)送時的順序)。當(dāng)建立連接后,其中一個程序要作為客戶端的角色,而另一個要在作為服務(wù)器??蛻舳素撠?zé)發(fā)起連接,而服務(wù)器的責(zé)任就是等待、傾聽和回應(yīng)連接。當(dāng)連接建立成功,雙方可以發(fā)送和接收數(shù)據(jù),直到連接關(guān)閉為止。用戶數(shù)據(jù)報協(xié)議不像TCP協(xié)議,用戶數(shù)據(jù)報協(xié)議(UDP)并不作以字節(jié)流的形式來顯示數(shù)據(jù),與其他程序交換數(shù)據(jù)時也不需要與另一個程序建立連接。以離散單元的形式交換的數(shù)據(jù)稱之為數(shù)據(jù)報,類似于IP數(shù)據(jù)報。事實上,UDP唯一的特點就是所提供的原始IP數(shù)據(jù)報是端口號和可選的校驗和。UDP有時被稱為是一個不可靠的協(xié)議,因為在網(wǎng)絡(luò)上一個程序發(fā)送一UDP數(shù)據(jù)報,是沒有辦法知道它是否確實到達它的目的
27、地。這意味著發(fā)送者和接收者必須在UDP協(xié)議之上執(zhí)行他們自己的應(yīng)用協(xié)議。TCP的許多工作(如生成校驗,確認收到的數(shù)據(jù)包,轉(zhuǎn)發(fā)丟包等)必須由應(yīng)用程序本身來體現(xiàn)出來。由于UDP的局限性,你可能會奇怪為什么它的使用還是如此廣泛。UDP與TCP相比存在著兩個關(guān)鍵領(lǐng)域優(yōu)勢:速度和數(shù)據(jù)包開銷。因為TCP是一個可靠的協(xié)議,這是不言而喻的,通過很長的報文來保證完整的數(shù)據(jù)到達它的目的地,結(jié)果導(dǎo)致了在網(wǎng)絡(luò)傳輸中交換了大量的信息包。 UDP并沒有這種開銷,比起TCP來要快的多 。在這些情況下,速度顯的極其重要,或者在網(wǎng)絡(luò)中所發(fā)送的數(shù)據(jù)包必須保持最低水平,這就是UDP解決問題的關(guān)鍵。Client Server Prog
28、ramming with WinsockAuthor S.S. AhmedIntroductionWinsock control comes with VB6 and is used to create applications that access the low-level functions of the Transmission Control Protocol/Internet Protocol (TCP/IP).Most of you might have worked with Internet Transfer Control which is very handy cont
29、rol when it comes to Internet Programming but there is another control which even more robust and helps programmers creating more flexible applications. Winsock control comes with VB6 and is used to create applications that access the low-level functions of the Transmission Control Protocol/Internet
30、 Protocol (TCP/IP).TCP/IP is a specification that defines a series of protocols used to standardize how computers exchange information with each other. TCP/IP provides communication across interconnected networks that use diverse hardware architectures and various operating systems. The protocols in
31、 TCP/IP are arranged in a series of layers known as a protocol stack. Each layer has its own functionality.Winsock is a standard that is maintained by Microsoft. This standard is basically a set of routines that describe communications from the TCP/IP stack. These routines reside in a dynamic link l
32、ibrary that runs under Windows. The winsock DLL is interfaced with TCP/IP and from there through the Internet.In this article, I am going to show how to use the winsock in a client server environment, we will create two separate applications, one of which will be a server and the other will be a cli
33、ent. Both client and server will interact with each other to exchange data. Client will send a request to the server and the server which will be connected to a database will retrieve the information requested by the client from the database and will return the requested information back to the clie
34、nt. You will base a database with this article, the database contains the item numbers and their prices. In real life situations, database might be located on a machine different from the one that hosts and client application.Ports & the WinSock ControlI think it would be better to talk about th
35、e ports before we proceed any further. A port is a special memory location that exists when two computers are incommunication via TCP/IP. Applications use a port number as an identifier to other computers, both the sending and receiving computers use this port to exchange data.To make the job of com
36、munication easier, some port numbers have beenstandardized. These standard port numbers have no inherent value other than that users have agreed to use them with certain applications. Table below lists a number of popular and publicly accepted port numbers and their corresponding applications.Using
37、the Winsock ControlWinsock is above the TCP/IP protocol stack in the ISO/OSI model. TCP/IP is an industry standard communication protocol that defines methods for packaging data into packets for transmission between computing devices on a heterogeneous network. TCP/IP is the standard for data transm
38、ission over networks, including the Internet. TCP establishes a connection for data transmission and IP defines the method for sending data packets.The Microsoft Winsock control makes using the TCP/IP a breeze. Microsoft has wrapped up the Winsock and INetAPI API calls into a nice neat package that
39、you can easily incorporate into your Visual Basic applications.Winsock Operating ModesThe Transport layer (also known as the Host-to-Host Transport layer) isresponsible for providing the Application layer with session and datagramcommunication services. The core protocols of the Transport layer are
40、TCP and User Datagram Protocol (UDP). The Winsock control supports the following two operating modes:sckTCPProtocol sckUDPProtocol WinSock Properties & EventsWinsock enables you to create clients and servers using the same control. This dual functionality enables you to specify through property
41、setting the type of application you will be building. The Winsock control uses a number of the same properties, whether you are creating client or a server, thereby all but eliminating the learning curve needed to create applications. Some of the important properties of the control are as following:
42、BytesReceived PropertyThis property returns the number of bytes currently in the receive buffer. This is a read-only property and is unavailable at design time. The value returned is a long integer.LocalHostName PropertyThe LocalHostName property returns the name of the local host system. This is re
43、ad-only property and is unavailable at the design time. The value returned is a string.LocalIP PropertyThis property returns or sets the local port number. This can be both read from and written to and is available at both design time and runtime. The value returned is a long integer.Protocol Proper
44、tyReturns or sets the protocol, either TCP or UDP, used by the Winsock control. RemoteHost PropertyThe RemoteHost property returns or sets the remote host. This can be both read from and written to and is available both in design time and runtime. The value returned is a string and can be specified
45、either as an IP address or as a DNS name. RemotePort PropertyThis property returns or sets the remote port number.State PropertyThis returns the state of the control as expressed by an enumerated list. This is read-only property and is unavailable at design time.Some of the important methods of Wins
46、ock control are as following:Accept MethodIt accepts the request for connection from the client system. For this method to be used, the control must be in the listening state.Close MethodThe Close method terminates a TCP connection from either the client or server applications.GetData MethodGetData
47、is the method that retrieves the current block of data from the buffer and then stores it in a variable of the variant type.PeekData MethodThe PeekData method operates in a fashion similar to the GetData method. However, it does not remove data from the input queue.Listen MethodThis is invoked on th
48、e server application to have the server application wait for a TCP request for connection from a client system.SendData MethodThis method dispatches data to the remote computer. It is used for both the client and server systems.Connect MethodThe Connect method requests a connection to a remote compu
49、ter.I am not going to discuss events here. You can find the complete details of events on the Microsoft site.譯文如下:使用Winsock客戶端/服務(wù)器編程介紹作者 S.S. Ahmed緒論在Visual Basic 6.0中的Winsock控件是被用來創(chuàng)建能夠存取、訪問低層次的傳輸控制協(xié)議/互聯(lián)網(wǎng)協(xié)議(TCP/IP)的應(yīng)用程序。當(dāng)談到網(wǎng)絡(luò)編程的時候,除了有另一種使用起來更有效并且能幫助程序員實現(xiàn)更靈活的應(yīng)用控件以外,大多數(shù)的情況下你有可能會使用非常便捷Internet Transfer
50、 控件。在Visual Basic 6.0中的Winsock控件是被用來創(chuàng)建能夠存取、訪問低層次的傳輸控制協(xié)議/互聯(lián)網(wǎng)協(xié)議(TCP/IP)的應(yīng)用程序 。TCP/IP是一組定義了一系列用來規(guī)范計算機如何交換信息的協(xié)議集。 它通過互聯(lián)網(wǎng)使用各種硬件體系結(jié)構(gòu)和操作系統(tǒng)來實現(xiàn)通信。在TCP/IP協(xié)議集中的各個協(xié)議都被分布在一系列層次之中而被視為一個協(xié)議堆棧。每一層都有其自身的功能。Winsock是由微軟公司推出的一個標準。這個標準基本上是一組通過TCP/IP 協(xié)議族來描述通信的程序。這些程序被保存在windows下的一個動態(tài)鏈接庫中。Winsock的動態(tài)鏈接庫是面向TCP/IP的,并且通過網(wǎng)絡(luò)可以調(diào)用。在這篇文章中,我將會說明在客戶端/服務(wù)器環(huán)境中如何使用Winsock,我們將會建立兩個獨立的應(yīng)用程序,其中一個作為服務(wù)器而另一個作為客戶端??蛻魴C和服務(wù)器將相互建立連接并且相互交換數(shù)據(jù)??蛻舳藢l(fā)送請求到服務(wù)器,已經(jīng)與數(shù)據(jù)庫
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 智能家居中的物聯(lián)網(wǎng)關(guān)鍵節(jié)點應(yīng)用-洞察闡釋
- 數(shù)據(jù)驅(qū)動決策提升智能化轉(zhuǎn)型效果
- 高中美術(shù)跨學(xué)科教學(xué)中的學(xué)生自主學(xué)習(xí)與合作學(xué)習(xí)
- 2025至2030年中國溫度/濕度/振動三綜合試驗箱行業(yè)投資前景及策略咨詢報告
- 2025至2030年中國汽車后轉(zhuǎn)向燈行業(yè)投資前景及策略咨詢報告
- 2025至2030年中國水產(chǎn)養(yǎng)殖技術(shù)行業(yè)投資前景及策略咨詢報告
- 2025至2030年中國橡膠防水油膏行業(yè)投資前景及策略咨詢報告
- 2025至2030年中國梳草碎根機行業(yè)投資前景及策略咨詢報告
- 2025至2030年中國松仁粽子糖行業(yè)投資前景及策略咨詢報告
- 2025至2030年中國智能數(shù)顯變送控制儀行業(yè)投資前景及策略咨詢報告
- 韓國流行音樂課件
- 新技術(shù)、新工藝、對提高工程質(zhì)量、縮短工期、降低造價的可行性
- 重慶大學(xué)大學(xué)化學(xué)Ⅰ期末考試卷A
- 全過程工程咨詢管理服務(wù)方案
- 級信管期末考試試卷a
- 信息科技課程標準新課標學(xué)習(xí)心得分享
- 四川大學(xué)宣傳介紹PPT
- 哈維麥凱人脈66表格
- 鋁合金門窗工程技術(shù)標
- 地理北極地區(qū)和南極地區(qū)課件
- 職業(yè)發(fā)展與就業(yè)指導(dǎo)課件制定求職計劃
評論
0/150
提交評論