2023年全國碩士研究生考試考研英語一試題真題(含答案詳解+作文范文)_第1頁
已閱讀1頁,還剩13頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認(rèn)領(lǐng)

文檔簡介

1、<p>  畢業(yè)設(shè)計(論文)外文文獻翻譯</p><p>  譯文一: Introduction to TCP/IP – Introduction</p><p>  譯文二: Client Server Programming with Winsock</p><p>  學(xué)生姓名 </p>&l

2、t;p>  學(xué) 號 </p><p>  系 別 信息與電子系 </p><p>  專業(yè)班級 計算機科學(xué)與技術(shù) </p><p>  Introduction to TCP/IP– Introduction</p><p>  Author C

3、atalyst Development</p><p>  Catalyst Development is a recognized leader in Internet component software whose award-winning products are used by thousands of corporate, government and independent developers

4、around the world.</p><p>  Introduction</p><p>  With the acceptance of TCP/IP as a standard platform-independent network protocol, and the explosive growth of the Internet, the Windows Sockets

5、API (application program interface) has emerged as the standard for network programming in the Windows environment. This document will introduce the basic concepts behind Windows Sockets programming and get you started w

6、ith your first application created with SocketWrench.</p><p>  SocketWrench is part of a package developed by Catalyst called the SocketTools Visual Edition. SocketTools includes components and libraries for

7、 many of the popular Internet application protocols, such as FTP, POP3, SMTP and HTTP. For more information about the complete SocketTools package, visit the Catalyst website at www.catalyst.com. It is assumed that the r

8、eader is familiar with Visual Basic and has installed the SocketWrench control.If you're already familiar with sockets programming, feel</p><p>  There are two general approaches that you can take when c

9、reating a program that 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.

10、 This can provide a more "natural" programming interface, and it allows you to avoid much of the error-prone drudgery commonly associated with sockets programming. By including the control in a project, setting

11、 some propert</p><p>  Transmission Control Protocol (TCP)</p><p>  When two computers wish to exchange information over a network, there are several components that must be in place before the

12、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 networking connections. Beyond thi

13、s physical connection, however, computers also need to use a protocol which defines the parameters of the communication between them. In short, a protocol</p><p>  By convention, TCP/IP is used to refer to a

14、 suite of protocols, all based on the Internet Protocol (IP). Unlike a single local network, where every system is directly connected to each other, an internet is a collection of networks, combined into a single, virtua

15、l network. The Internet Protocol provides the means by which any system on any network can communicate with another as easily as if they were on the same physical network. Each system, commonly referred to as a host, is

16、assigned a unique</p><p>  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 datagram consists of a

17、 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

18、. And like postal mail, there is no guarantee that a datagram will actually arrive at it's destination. </p><p>  To fill this need, the Transmission Control Protocol (TCP) was developed. Built on top of

19、 IP, TCP offers a reliable, full-duplex byte stream which may be read and written to in a fashion similar to reading and writing a file. The advantages to this are obvious: the application programmer doesn't need to

20、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 adopte</p><p>  TC

21、P 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

22、both sides exchange packets and establish the initial packet sequence 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 r

23、eceived in the order that it was sent). When establishing a connecti</p><p>  User Datagram Protocol</p><p>  Unlike TCP, the User Datagram Protocol (UDP) does not present data as a stream of by

24、tes, 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 f

25、eatures that UDP offers over raw IP datagrams are port numbers and an optional checksum.</p><p>  UDP is sometimes referred to as an unreliable protocol because when a program sends a UDP datagram over the n

26、etwork, there is no way for it to know that it actually arrived at it's destination. This means that the sender and receiver must typically implement their own application protocol on top of UDP. Much of the work tha

27、t TCP does transparently (such as generating checksums, acknowledging the receipt of packets, retransmitting lost packets and so on) must be performed by the application itsel</p><p>  With the limitations o

28、f 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 arr

29、ives at it's destination intact, and as a result it exchanges a fairly high number of packets over the network. UDP doesn't have this overhead, and is considerably faster than TCP. In those situations where speed

30、 is paramount, or the number of packets sent over </p><p><b>  譯文如下:</b></p><p>  TCP/IP入門介紹</p><p>  作者 Catalyst Development</p><p>  Catalyst Development

31、是全球公認(rèn)的領(lǐng)先的互聯(lián)網(wǎng)軟件之一,其屢獲殊榮的產(chǎn)品已廣泛為世界各地成千上萬的企業(yè)、政府和獨立開發(fā)商所使用。</p><p><b>  緒論</b></p><p>  隨著TCP/IP作為一種獨立網(wǎng)絡(luò)協(xié)議標(biāo)準(zhǔn)平臺逐漸的被認(rèn)可,以及互聯(lián)網(wǎng)的激增,在Windows環(huán)境下成為網(wǎng)絡(luò)程序設(shè)計標(biāo)準(zhǔn)的Windows Sockets API (應(yīng)用程序結(jié)口)已經(jīng)步入舞臺。在Wind

32、ows Sockets編程之后,本文將介紹基本概念并且使用SocketWrench來實現(xiàn)你的第一個應(yīng)用程序。</p><p>  Socketwrench是Catalyst軟件開發(fā)的其中一部分,稱之為SocketTools Visual Edition。SocketTools容納了一些備受歡迎的互聯(lián)網(wǎng)應(yīng)用協(xié)議的組件及類庫,如ftp ,pop3 , smtp和http。欲了解更多關(guān)于sockettools軟件包,請

33、訪問Catalyst網(wǎng)站www.catalyst.com 。假定讀者已經(jīng)熟悉可視化程序設(shè)計而且已經(jīng)安裝了SocketWrench控件,如果你對socket編程已經(jīng)有所了解,那你可以跳過這一節(jié)的內(nèi)容…</p><p>  當(dāng)在利用Windows Sockets創(chuàng)建一個程序時,有兩個基本途徑。其中一個就是使用API函數(shù)編寫代碼。另外一種方式是通過設(shè)置屬性和響應(yīng)事件來使用所提供的更高層次的接口的組件。它提供了一種更加適

34、當(dāng)?shù)木幊探涌?,使用sockets編程可以避免許多易錯點。在工程部件里包含了這個控件,設(shè)置它的屬性和響應(yīng)它的事件你可以更加迅速而容易的實現(xiàn)網(wǎng)絡(luò)程序的應(yīng)用。socketwrench提供了比較全面的Windows Sockets類庫,并且在文章中的下一部分會被用來建立一個簡單的客戶機-服務(wù)器應(yīng)用。在開始利用該控件編程之前,我們先來學(xué)習(xí)一下通常sockets編程中基本術(shù)語和概念。</p><p><b>  傳

35、輸控制協(xié)議</b></p><p>  當(dāng)兩臺電腦之間想通過網(wǎng)絡(luò)交換信息,在真正傳輸和接收數(shù)據(jù)之前,有幾個組成部分是必須的。當(dāng)然,物理硬件必須存在,像典型的網(wǎng)絡(luò)接口卡(網(wǎng)卡)或一個撥號網(wǎng)絡(luò)連接的串行通信端口。盡管如此,在這些物理連接之外,計算機之間同樣也需要定義一些參數(shù)傳遞的協(xié)議??傊?,一個協(xié)議定義了“信息通信的規(guī)則”,網(wǎng)絡(luò)中的每臺計算機必須遵循以便使所有的系統(tǒng)可以進行數(shù)據(jù)交換。在當(dāng)今最流行的協(xié)議就是

36、TCP/IP,也即傳輸控制協(xié)議。</p><p>  按照慣例,TCP/IP是一整套協(xié)議,都是基于互聯(lián)網(wǎng)協(xié)議(IP協(xié)議)。不像一個單一的本地網(wǎng),每個系統(tǒng)是直接連接到對方,互聯(lián)網(wǎng)是一個網(wǎng)絡(luò)的集合,結(jié)合了單個的、虛擬的網(wǎng)絡(luò)。互聯(lián)網(wǎng)協(xié)議規(guī)定,如果在相同的物理網(wǎng)絡(luò)中,在任何網(wǎng)絡(luò)上的任何系統(tǒng)都能夠很輕易的實現(xiàn)通信。每個系統(tǒng),通常被稱為主機,分配一個唯一的用來辨別的32位數(shù)字。通常情況下,這個地址通過點分為四個8位的數(shù)字。這

37、就是所謂的點分法,類似“192.43.19.64”。其中有一部分地址用于識別網(wǎng)絡(luò)系統(tǒng)連接的,而其余的是用來識別系統(tǒng)本身的。不對Internet 地址進行詳細的了解了,只要知道主要的3“類”地址,如“A”,“B”和“C”。一般規(guī)則是“A”類地址被分配到一些非常大型的網(wǎng)絡(luò),“B”類地址被分配到中等規(guī)模的網(wǎng)絡(luò),而“C”類地址分配給小型網(wǎng)絡(luò)(網(wǎng)絡(luò)少于有250臺主機) 。</p><p>  當(dāng)一個系統(tǒng)通過互聯(lián)網(wǎng)協(xié)議發(fā)送數(shù)

38、據(jù)時,所發(fā)送的不連續(xù)的單位即所謂的數(shù)據(jù)報,也被稱為信息包。一個數(shù)據(jù)報是有報頭和數(shù)據(jù)組成。報頭包含了數(shù)據(jù)報要傳遞的目的地址的信息,就像一個信封,是用來書寫地址、郵件處理。像郵件一樣,不能保證數(shù)據(jù)報就能到達它的目的地。事實上,數(shù)據(jù)報在網(wǎng)絡(luò)傳輸過程中也可能會出現(xiàn)丟失、重復(fù)或無序現(xiàn)象。不用說,這種不可靠性,可能會給軟件開發(fā)人員造成很多問題。那怎么樣才可以實現(xiàn)可靠的、直接的交換數(shù)據(jù),而不出現(xiàn)信息報丟失或者無序的現(xiàn)象。</p><

39、;p>  傳輸控制協(xié)議(TCP)的發(fā)展就是為了滿足這個需求。建立在IP基礎(chǔ)上,TCP提供了一個可靠的、全雙工的字節(jié)流可讀可寫類似于對文件的讀寫操作。它的優(yōu)點是顯而易見的:程序員并不需要編寫代碼來處理丟失或無序的數(shù)據(jù)報,而是可以專注于應(yīng)用程序本身。因為數(shù)據(jù)是作為一個字節(jié)流來保存的,使用TCP可以更加容易的修改和使用現(xiàn)有的代碼。</p><p>  眾所周知,TCP是面向連接的協(xié)議。在換句話說,在兩個程序開始進

40、行數(shù)據(jù)交換之前,他們必須建立一個連接 。采用三次握手在雙方交換信息包并且建立初始的序號(序號是非常重要的,因為正如上文所述,數(shù)據(jù)可能出現(xiàn)無序現(xiàn)象,序號可以用來保證數(shù)據(jù)報發(fā)送時的順序)。當(dāng)建立連接后,其中一個程序要作為客戶端的角色,而另一個要在作為服務(wù)器??蛻舳素撠?zé)發(fā)起連接,而服務(wù)器的責(zé)任就是等待、傾聽和回應(yīng)連接。當(dāng)連接建立成功,雙方可以發(fā)送和接收數(shù)據(jù),直到連接關(guān)閉為止。</p><p><b>  用戶

41、數(shù)據(jù)報協(xié)議</b></p><p>  不像TCP協(xié)議,用戶數(shù)據(jù)報協(xié)議(UDP)并不作以字節(jié)流的形式來顯示數(shù)據(jù),與其他程序交換數(shù)據(jù)時也不需要與另一個程序建立連接。以離散單元的形式交換的數(shù)據(jù)稱之為數(shù)據(jù)報,類似于IP數(shù)據(jù)報。事實上,UDP唯一的特點就是所提供的原始IP數(shù)據(jù)報是端口號和可選的校驗和。</p><p>  UDP有時被稱為是一個不可靠的協(xié)議,因為在網(wǎng)絡(luò)上一個程序發(fā)送一U

42、DP數(shù)據(jù)報,是沒有辦法知道它是否確實到達它的目的地。這意味著發(fā)送者和接收者必須在UDP協(xié)議之上執(zhí)行他們自己的應(yīng)用協(xié)議。TCP的許多工作(如生成校驗,確認(rèn)收到的數(shù)據(jù)包,轉(zhuǎn)發(fā)丟包等)必須由應(yīng)用程序本身來體現(xiàn)出來。</p><p>  由于UDP的局限性,你可能會奇怪為什么它的使用還是如此廣泛。UDP與TCP相比存在著兩個關(guān)鍵領(lǐng)域優(yōu)勢:速度和數(shù)據(jù)包開銷。因為TCP是一個可靠的協(xié)議,這是不言而喻的,通過很長的報文來保證完

43、整的數(shù)據(jù)到達它的目的地,結(jié)果導(dǎo)致了在網(wǎng)絡(luò)傳輸中交換了大量的信息包。 UDP并沒有這種開銷,比起TCP來要快的多 。在這些情況下,速度顯的極其重要,或者在網(wǎng)絡(luò)中所發(fā)送的數(shù)據(jù)包必須保持最低水平,這就是UDP解決問題的關(guān)鍵。</p><p>  Client Server Programming with Winsock</p><p>  Author S.S. Ahmed</p&

44、gt;<p>  S.S. Ahmed is a senior IT Professional and works for a web and software development firm. Ahmed specializes in creating database driven dynamic web sites. He has been working with SharePoint for the last

45、3-4 years. He develops customized SharePoint solutions. Ahmed enjoys travelling and has been to many parts of the world. Web: www.walisystems.com Blog: www.sharepointblogs.com/ssa.</p><p>  Introduction</

46、p><p>  Winsock 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).</p><p>  Most of you m

47、ight have worked with Internet Transfer Control which is very handy control when it comes to Internet Programming but there is another control which even more robust and helps programmers creating more flexible applicati

48、ons. Winsock 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). </p><p>  TCP/IP is a specification

49、 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

50、 operating systems. The protocols in TCP/IP are arranged in a series of layers known as a protocol stack. Each layer has its own functionality. </p><p>  Winsock is a standard that is maintained by Microsoft

51、. This standard is basically a set of routines that describe communications from the TCP/IP stack. These routines reside in a dynamic link library that runs under Windows. The winsock DLL is interfaced with TCP/IP and fr

52、om there through the Internet.</p><p>  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

53、the other will be a client. 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 informati

54、on requested by the client from the database and will return the requested information back to the client. You wi</p><p>  Ports & the WinSock Control</p><p>  I think it would be better to

55、talk about the ports before we proceed any further. A port is a special memory location that exists when two computers are in communication via TCP/IP. Applications use a port number as an identifier to other computers,

56、both the sending and receiving computers use this port to exchange data. </p><p>  To make the job of communication easier, some port numbers have been standardized. These standard port numbers have no inher

57、ent 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.</p><p>  Usin

58、g the Winsock Control</p><p>  Winsock 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

59、transmission between computing devices on a heterogeneous network. TCP/IP is the standard for data transmission over networks, including the Internet. TCP establishes a connection for data transmission and IP defines the

60、 method for sending data packets.</p><p>  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 you can easi

61、ly incorporate into your Visual Basic applications.</p><p>  Winsock Operating Modes</p><p>  The Transport layer (also known as the Host-to-Host Transport layer) is responsible for providing th

62、e Application layer with session and datagram communication services. The core protocols of the Transport layer are TCP and User Datagram Protocol (UDP). The Winsock control supports the following two operating modes:<

63、;/p><p>  sckTCPProtocol</p><p>  sckUDPProtocol </p><p>  WinSock Properties & Events</p><p>  Winsock enables you to create clients and servers using the same contro

64、l. This dual functionality enables you to specify through property 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 serv

65、er, thereby all but eliminating the learning curve needed to create applications. Some of the important properties of the control are as following:</p><p>  BytesReceived Property</p><p>  This

66、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.</p><p>  LocalHostName Property<

67、/p><p>  The LocalHostName property returns the name of the local host system. This is read-only property and is unavailable at the design time. The value returned is a string. </p><p>  LocalIP Pr

68、operty</p><p>  The LocalIP property returns the local host system IP address in the form of a string, such as 11.0.0.127. This property is read-only and is unavailable at design time. </p><p> 

69、 LocalPort Property</p><p>  This 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 inte

70、ger.</p><p>  Protocol Property</p><p>  Returns or sets the protocol, either TCP or UDP, used by the Winsock control.</p><p>  RemoteHost Property</p><p>  The RemoteH

71、ost 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 either as an IP address or as

72、a DNS name.</p><p>  RemotePort Property</p><p>  This property returns or sets the remote port number.</p><p>  State Property</p><p>  This returns the state of the c

73、ontrol as expressed by an enumerated list. This is read-only property and is unavailable at design time.</p><p>  Some of the important methods of Winsock control are as following:</p><p>  Acce

74、pt Method</p><p>  It accepts the request for connection from the client system. For this method to be used, the control must be in the listening state.</p><p>  Close Method</p><p>

75、;  The Close method terminates a TCP connection from either the client or server applications.</p><p>  GetData Method</p><p>  GetData is the method that retrieves the current block of data fro

76、m the buffer and then stores it in a variable of the variant type. </p><p>  PeekData Method</p><p>  The PeekData method operates in a fashion similar to the GetData method. However, it does no

77、t remove data from the input queue.</p><p>  Listen Method</p><p>  This is invoked on the server application to have the server application wait for a TCP request for connection from a client s

78、ystem.</p><p>  SendData Method</p><p>  This method dispatches data to the remote computer. It is used for both the client and server systems.</p><p>  Connect Method</p>&l

79、t;p>  The Connect method requests a connection to a remote computer.</p><p>  I am not going to discuss events here. You can find the complete details of events on the Microsoft site.</p><p>

80、<b>  譯文如下:</b></p><p>  使用Winsock客戶端/服務(wù)器編程–介紹</p><p>  作者 S.S. Ahmed</p><p>  S.S. Ahmed是一名資深的IT專家,工作于網(wǎng)絡(luò)軟件開發(fā)公司。Ahmed致力于開發(fā)數(shù)據(jù)庫驅(qū)動的動態(tài)網(wǎng)站。他曾與SharePoint一起并肩合作過3-4年的時間。他開發(fā)定制了Sha

81、rePoint的解決方案。Ahmed喜歡旅行,到過世界的許多地方。網(wǎng)址: www.walisystems.com博客: www.sharepointblogs.com / ssa</p><p><b>  緒論</b></p><p>  在Visual Basic 6.0中的Winsock控件是被用來創(chuàng)建能夠存取、訪問低層次的傳輸控制協(xié)議/互聯(lián)網(wǎng)協(xié)議(TCP/IP

82、)的應(yīng)用程序。</p><p>  當(dāng)談到網(wǎng)絡(luò)編程的時候,除了有另一種使用起來更有效并且能幫助程序員實現(xiàn)更靈活的應(yīng)用控件以外,大多數(shù)的情況下你有可能會使用非常便捷Internet Transfer 控件。在Visual Basic 6.0中的Winsock控件是被用來創(chuàng)建能夠存取、訪問低層次的傳輸控制協(xié)議/互聯(lián)網(wǎng)協(xié)議(TCP/IP)的應(yīng)用程序 。</p><p>  TCP/IP是一組定義

83、了一系列用來規(guī)范計算機如何交換信息的協(xié)議集。 它通過互聯(lián)網(wǎng)使用各種硬件體系結(jié)構(gòu)和操作系統(tǒng)來實現(xiàn)通信。在TCP/IP協(xié)議集中的各個協(xié)議都被分布在一系列層次之中而被視為一個協(xié)議堆棧。每一層都有其自身的功能。</p><p>  Winsock是由微軟公司推出的一個標(biāo)準(zhǔn)。這個標(biāo)準(zhǔn)基本上是一組通過TCP/IP</p><p>  協(xié)議族來描述通信的程序。這些程序被保存在windows下的一個動態(tài)鏈

84、接庫中。Winsock的動態(tài)鏈接庫是面向TCP/IP的,并且通過網(wǎng)絡(luò)可以調(diào)用。</p><p>  在這篇文章中,我將會說明在客戶端/服務(wù)器環(huán)境中如何使用Winsock,我們將會建立兩個獨立的應(yīng)用程序,其中一個作為服務(wù)器而另一個作為客戶端??蛻魴C和服務(wù)器將相互建立連接并且相互交換數(shù)據(jù)??蛻舳藢l(fā)送請求到服務(wù)器,已經(jīng)與數(shù)據(jù)庫建立連接的服務(wù)器將接受客戶端所發(fā)送的數(shù)據(jù),同時把請求信息返回到客戶端。在這篇文章中你需要建立

85、一個數(shù)據(jù)庫,該數(shù)據(jù)庫包含了該項目的數(shù)量和價格。在現(xiàn)實條件下,數(shù)據(jù)庫可能局限于一臺機器上而與客戶端、服務(wù)器應(yīng)用有所差別。</p><p>  Winsock控件的使用</p><p>  在國際標(biāo)準(zhǔn)化組織/開放系統(tǒng)互連(ISO/OSI)模型中,Winsock要高于TCP/IP協(xié)議族。 TCP/IP是一個工業(yè)化標(biāo)準(zhǔn)的通信協(xié)議,它定義了將數(shù)據(jù)封裝成信息包在異構(gòu)網(wǎng)絡(luò)上的設(shè)備之間進行傳輸。 TCP/

86、IP就是這樣一種將數(shù)據(jù)通過網(wǎng)絡(luò),包括互聯(lián)網(wǎng)傳輸?shù)臉?biāo)準(zhǔn)。TCP為數(shù)據(jù)傳輸建立了連接,而IP為數(shù)據(jù)包的發(fā)送定義了模式。</p><p>  微軟的Winsock控件使用TCP/IP是一件輕而易舉的事。微軟已經(jīng)對Winsock和INetAPI API進行封裝打包,因此你就可以更加容易實現(xiàn)可視化程序設(shè)計的一體化應(yīng)用。</p><p>  端口與Winsock控件</p><p&

87、gt;  在我們進行深層次的學(xué)習(xí)之前,我認(rèn)為應(yīng)該先談?wù)動嘘P(guān)于端口的內(nèi)容。當(dāng)兩臺電腦之間通過TCP/IP進行通信時,端口作為一個特殊的存儲位置而存在。申請使用的一個端口號作為其他電腦的識別碼,無論是發(fā)送方還是接收方計算機都是使用這個端口進行數(shù)據(jù)交換的。</p><p>  為了使通信能夠更加容易的實現(xiàn),一些端口號已經(jīng)規(guī)范化。這些標(biāo)準(zhǔn)的端口號除了用戶在某個應(yīng)用程序中使用之外,沒有任何內(nèi)在的價值。下表列出了一些常用的,

88、并且被公眾所接受的端口號以及其相應(yīng)的應(yīng)用。</p><p>  Winsock的操作模式</p><p>  傳輸層(也稱為主機到主機傳輸層),負責(zé)提供應(yīng)用層與會話層及數(shù)據(jù)通訊服務(wù)。傳輸層的核心協(xié)議是TCP和用戶數(shù)據(jù)報協(xié)議(UDP)。該Winsock控件支持以下兩種操作模式:</p><p>  sckTCPProtocol TCP 協(xié)議</p&g

89、t;<p>  sckUDPProtocol UDP 協(xié)議</p><p>  Winsock的屬性與事件</p><p>  Winsock允許您使用相同的控件創(chuàng)建客戶端和服務(wù)器。您可以通過屬性的設(shè)置來實現(xiàn)你想要創(chuàng)建的應(yīng)用程序的類型以至于實現(xiàn)服務(wù)器和客戶端的雙重功能。無論是客戶端還是服務(wù)器,Winsock控件使用了許多相同的屬性,從而在實際應(yīng)用過程中可以避免一些

90、學(xué)習(xí)的彎路??丶囊恍┲匾膶傩匀缦聨c:</p><p>  BytesReceived屬性</p><p>  這個屬性返回的是在當(dāng)前字緩沖區(qū)里的字節(jié)數(shù)。這是一個只讀的屬性,在程序設(shè)計期間是不可見的。所返回的是一個長整形的值。</p><p>  LocalHostName屬性</p><p>  localhostname屬性返回的是本

91、地主機名。這是一個只讀的屬性,在程序設(shè)計期間是不可見的。所返回的值是一個字符串類型。</p><p><b>  LocalIP屬性</b></p><p>  LocalIP屬性是以字符串形式返回本地IP地址,如11.0.0.127 。這是一個只讀的屬性,在程序設(shè)計期間是不可見的。</p><p>  LocalPort屬性</p>

92、;<p>  這個屬性是用來返回或設(shè)置本地端口號。它既可讀也可寫,并在程序設(shè)計和運行期間是可見的。所返回的是一個長整形的值。</p><p>  Protocol屬性</p><p>  該屬性是用來返回或設(shè)置協(xié)議的,通過Winsock控件來使用TCP 或UDP協(xié)議進行傳輸。</p><p>  RemoteHost屬性</p><

93、p>  Remotehost屬性是用來返回或設(shè)置遠程主機的。它既可讀也可寫,在程序設(shè)計和運行期間是可見的。所返回的是一個字符串類型的值,被指定的值要么是一個IP地址或者是一個DNS名。</p><p>  RemotePort屬性</p><p>  這個屬性返回或設(shè)置遠程端口號。</p><p><b>  State屬性</b><

94、;/p><p>  所返回的控件狀態(tài)可以表述為一張列表。它既可讀也可寫,在程序設(shè)計和運行期間是可見的。</p><p>  以下幾點是Winsock控件的一些重要的方法:</p><p><b>  Accept方法</b></p><p>  接受來自于客戶端的連接請求。只有當(dāng)服務(wù)器處于監(jiān)聽狀態(tài)時,這種模式才可能實現(xiàn)。&l

95、t;/p><p><b>  Close方法</b></p><p>  該模式是終止服務(wù)器和客戶端之間的連接狀態(tài)。</p><p><b>  GetData方法</b></p><p>  GetData方法是從緩沖區(qū)接收當(dāng)前的數(shù)據(jù)塊,然后把它存儲在變量中。</p><p>

96、  PeekData方法</p><p>  peekdata方法操作與GetData方法相似。但PeekData 不從輸入隊列中移去數(shù)據(jù)。</p><p><b>  Listen方法</b></p><p>  此方法是由服務(wù)器應(yīng)用程序來調(diào)用等待接收來自于客戶端的請求。</p><p>  SendData方法<

溫馨提示

  • 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. 眾賞文庫僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論