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

下載本文檔

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

文檔簡(jiǎn)介

1、<p><b>  中文3078字</b></p><p>  使用LabVIEW中的TCP/IP和UDP協(xié)議</p><p><b>  前言</b></p><p>  互聯(lián)網(wǎng)絡(luò)協(xié)議(IP),用戶數(shù)據(jù)報(bào)協(xié)議(UDP)和傳輸控制協(xié)議(TCP)是網(wǎng)絡(luò)通信的基本的工具。TCP與IP的名稱來(lái)自于一組最著名的因特網(wǎng)協(xié)議

2、中的兩個(gè)--傳輸控制協(xié)議和互聯(lián)網(wǎng)絡(luò)協(xié)議。</p><p>  你能使用TCP/IP來(lái)進(jìn)行單一網(wǎng)絡(luò)或者互連網(wǎng)絡(luò)間的通信。單獨(dú)的網(wǎng)絡(luò)會(huì)被大的地理距離分隔。TCP/IP把數(shù)據(jù)從一個(gè)子網(wǎng)網(wǎng)絡(luò)或者因特網(wǎng)連接的計(jì)算機(jī)發(fā)送到另一個(gè)上。因?yàn)門CP/IP在大多數(shù)計(jì)算機(jī)上是可用的,它能在多樣化的系統(tǒng)中間傳送信息。</p><p>  LabVIEW和TCP/IP</p><p>  你

3、能在所有平臺(tái)上的LabVIEW中使用TCP/IP。LabVIEW包含了TCP和UDP程序還有能讓你建立客戶端或者服務(wù)器程序的功能。</p><p><b>  IP</b></p><p>  IP執(zhí)行低層次的計(jì)算機(jī)間的數(shù)據(jù)傳送。在組成部分里的IP數(shù)據(jù)包稱為數(shù)據(jù)報(bào)。一個(gè)數(shù)據(jù)報(bào)包含表明來(lái)源和目的地地址的數(shù)據(jù)和報(bào)頭字。IP為通過(guò)網(wǎng)絡(luò)或者因特網(wǎng)把數(shù)據(jù)發(fā)送到指定的目的地的數(shù)據(jù)

4、報(bào)確定正確的路徑。</p><p>  IP協(xié)議并不能保證發(fā)送。事實(shí)上,如果數(shù)據(jù)報(bào)在傳輸中被復(fù)制,IP可能多次傳送一個(gè)單獨(dú)的數(shù)據(jù)報(bào)。所以,程序很少用IP而是用TCP或者UDP代替。</p><p><b>  UDP</b></p><p>  UDP在計(jì)算機(jī)進(jìn)程中提供簡(jiǎn)單而低層次的通信。進(jìn)程通過(guò)把數(shù)據(jù)報(bào)發(fā)送到一個(gè)目的地計(jì)算機(jī)或者端口進(jìn)行通信。

5、一個(gè)端口是你發(fā)送數(shù)據(jù)的位置。IP處理計(jì)算機(jī)對(duì)計(jì)算機(jī)的發(fā)送。在數(shù)據(jù)報(bào)到達(dá)目的地計(jì)算機(jī)后,UDP把數(shù)據(jù)報(bào)移動(dòng)到其目的端口。如果目的端口不是開(kāi)放的,UDP將刪除數(shù)據(jù)報(bào)。UDP將發(fā)生IP的同樣的發(fā)送問(wèn)題。</p><p>  應(yīng)用程序的UDP的可靠性不強(qiáng)。例如,一項(xiàng)應(yīng)用程序能經(jīng)常把大量信息的數(shù)據(jù)傳送到目的地而丟失少量的數(shù)據(jù)是肯定的。</p><p>  在LabVIEW中使用UDP協(xié)議</p

6、><p>  因?yàn)閁DP不是一個(gè)TCP似的一個(gè)以連接為基礎(chǔ)的協(xié)議,在你發(fā)送或者收到數(shù)據(jù)之前,你不需要和目的地建立一種連接。相反,當(dāng)你每發(fā)送一個(gè)數(shù)據(jù)報(bào)時(shí),由你指定數(shù)據(jù)目的地。操作系統(tǒng)不會(huì)報(bào)告?zhèn)鬏敳铄e(cuò)</p><p>  使用UDP打開(kāi)功能在一個(gè)端口上打開(kāi)一個(gè)UDP插口。同時(shí)打開(kāi)的UDP端口的數(shù)量仍依賴于操作系統(tǒng)。UDP的打開(kāi)的功能返回到網(wǎng)絡(luò)連接時(shí)唯一識(shí)別UDP套接字。使用這種連接在子VI程序中就

7、是靠這個(gè)套接字。</p><p>  用UDP編寫功能發(fā)送數(shù)據(jù)到目的地,然后使用UDP閱讀功能閱讀那個(gè)數(shù)據(jù)。每寫一個(gè)操作要求一個(gè)目的地地址和端口。每閱讀一個(gè)操作包含來(lái)源地址和端口。UDP保存你所發(fā)送的每一個(gè)命令所指定的數(shù)據(jù)報(bào)字節(jié)。</p><p>  在理論上,你能發(fā)送任何大小的數(shù)據(jù)報(bào)。然而,你最好不使用UDP來(lái)發(fā)送大的數(shù)據(jù)報(bào),因?yàn)樗幌馮CP一樣可靠。</p><p&

8、gt;  當(dāng)你在一個(gè)端口上結(jié)束所有通信時(shí),使用UDP結(jié)束功能去釋放系統(tǒng)資源。</p><p><b>  UDP多路廣播</b></p><p>  你能使用UDP的功能來(lái)與一個(gè)單獨(dú)的客戶端通信或者通過(guò)廣播對(duì)于所有局域網(wǎng)上的計(jì)算機(jī)通信。如果你想要傳送成倍增加具體的計(jì)算機(jī)信息,你必須通過(guò)客戶端列表構(gòu)建UDP功能反復(fù)執(zhí)行。因?yàn)長(zhǎng)abVIEW能把數(shù)據(jù)的作為一個(gè)單獨(dú)的拷貝發(fā)送

9、到每個(gè)客戶端并且保存對(duì)收到數(shù)據(jù)感興趣的客戶端列表,所以運(yùn)用這種技術(shù)建立完全相同的網(wǎng)絡(luò)交換。</p><p>  使用多路廣播可以在網(wǎng)絡(luò)上的進(jìn)行單個(gè)的發(fā)送端和多倍的客戶端之間的通信而不需要保存客戶列表或者要求發(fā)送端把數(shù)據(jù)多重拷貝后發(fā)送給每個(gè)客戶端。為了通過(guò)多路廣播收到數(shù)據(jù)廣播,所有客戶端必須加入一個(gè)多路廣播組。而發(fā)送端不需要加入該組。發(fā)送端只需規(guī)定一個(gè)多路廣播的IP地址來(lái)定義這個(gè)多路廣播組。多路廣播的IP地址范圍在

10、224.0.0.0到239.255.255.255中。當(dāng)一個(gè)客戶端想要加入一個(gè)多路廣播組時(shí),它只需預(yù)定這個(gè)組的多路廣播的IP地址。在客戶端預(yù)定到一個(gè)多路廣播組之后,客戶端收到從多路廣播的IP地址發(fā)送的數(shù)據(jù)。</p><p>  對(duì)于LabVIEW中的多路廣播,使用UDP多路廣播的打開(kāi)程序有能力讀、寫或者讀和寫UDP數(shù)據(jù)。規(guī)定TTL為寫數(shù)據(jù),多路廣播地址為讀數(shù)據(jù),多路廣播端口號(hào)為讀寫數(shù)據(jù)。默認(rèn)TTL是1,這意味著L

11、abVIEW僅僅把數(shù)據(jù)報(bào)發(fā)送到本地的網(wǎng)絡(luò)上。當(dāng)一個(gè)發(fā)送方收到一個(gè)多路廣播數(shù)據(jù)報(bào)時(shí),它消耗數(shù)據(jù)報(bào)的生存時(shí)間。如果TTL大于1,發(fā)送方把數(shù)據(jù)報(bào)轉(zhuǎn)發(fā)到其它數(shù)據(jù)報(bào)。下面的表格說(shuō)明了當(dāng)你規(guī)定一個(gè)TTL的值時(shí),一個(gè)多路廣播數(shù)據(jù)報(bào)的運(yùn)行。</p><p>  如果你規(guī)定一個(gè)值大于1,數(shù)據(jù)報(bào)通過(guò)TTL-1層被發(fā)送,并且發(fā)送方轉(zhuǎn)發(fā)它。</p><p>  參閱在LabVIEW\例子\comm\UDP.llb

12、中的UDP多路廣播接受方程序和UDP多路廣播發(fā)送方程序VI中使用UDP多路廣播的例程。</p><p><b>  TCP</b></p><p>  TCP保證在網(wǎng)絡(luò)中的可靠的通信,按順序發(fā)送而沒(méi)有差錯(cuò),損失或者重發(fā)。TCP直到收到一個(gè)確認(rèn)才轉(zhuǎn)發(fā)。</p><p><b>  系統(tǒng)要求</b></p>&l

13、t;p>  在使用TCP/IP之前,確認(rèn)你有必需的要求,這變化依賴于你使用的平臺(tái)。</p><p>  (Windows和UNIX系統(tǒng))TCP/IP。 你不需要使用第三種產(chǎn)品連接使用TCP/IP。如果你的網(wǎng)絡(luò)適當(dāng)?shù)乇粯?gòu)成,LabVIEW沒(méi)有要求附加的設(shè)置。</p><p>  (Mac OS系統(tǒng)) LabVIEW網(wǎng)絡(luò)要求打開(kāi)傳送,包括Mac OS 7.5和更新的版本。</p&g

14、t;<p>  在LabVIEW中使用TCP</p><p>  TCP是一個(gè)以連接為基礎(chǔ)的協(xié)議,這意味著站點(diǎn)必須在傳送數(shù)據(jù)之前建立一種連接。TCP許可多重、同時(shí)的連接。</p><p>  你可以通過(guò)等待一種輸入的連接或者通過(guò)積極地尋求一種與指定的地址連接建立連接。在建立TCP連接時(shí),你必須指定一個(gè)地址和該地址的端口。端口范圍在0到65,535點(diǎn)之間。UNIX系統(tǒng)為特殊的應(yīng)

15、用程序保留端口數(shù)少于1,024。在一個(gè)給定的地址中不同的端口能識(shí)別不同的服務(wù)。</p><p>  使用TCP的打開(kāi)連接功能來(lái)與一個(gè)指定地址進(jìn)行積極的連接。如果連接成功,功能返回網(wǎng)絡(luò)連接的返回?cái)?shù)唯一識(shí)別那個(gè)連接。使用這種連接refnum來(lái)訪問(wèn)子VI程序。</p><p>  你能使用如下技術(shù)來(lái)等輸入連接:</p><p>  用TCP聽(tīng)程序創(chuàng)建立一個(gè)聽(tīng)者并且在一個(gè)指

16、定的端口等待一種可接受的TCP連接。如果連接成功,VI程序返回連接數(shù),地址和遠(yuǎn)程TCP客戶端口。</p><p>  TCP創(chuàng)建聽(tīng)者功創(chuàng)建一個(gè)聽(tīng)者然后用TCP的聽(tīng)者功能上等待的一個(gè)聽(tīng)者接受新的連接。在聽(tīng)者功能上的TCP等待返回你所發(fā)送的功能和返回?cái)?shù)的同樣的聽(tīng)者ID。當(dāng)你結(jié)束等候新的連接時(shí),用TCP關(guān)閉連接功能區(qū)關(guān)閉一個(gè)聽(tīng)者。你不能對(duì)一個(gè)聽(tīng)者進(jìn)行讀寫。</p><p>  用第二種技術(shù)的優(yōu)勢(shì)

17、是你能使用TCP關(guān)閉連接功能來(lái)取消聽(tīng)操作,這在你想要為了一種連接聽(tīng)而沒(méi)有超時(shí),但是你想要取消當(dāng)另一個(gè)條件變真時(shí)的聽(tīng)時(shí)是很有用的。你能在任何時(shí)間關(guān)閉聽(tīng)程序。</p><p>  當(dāng)你建立一種連接時(shí),用TCP讀功能和TCP寫功能能在遠(yuǎn)程應(yīng)用中隊(duì)數(shù)據(jù)進(jìn)行讀寫。</p><p>  用TCP關(guān)閉連接功能區(qū)關(guān)閉遠(yuǎn)程連接。如果沒(méi)被讀的仍保留著而關(guān)閉連接,你可能失去數(shù)據(jù)。當(dāng)關(guān)閉連接時(shí),在你的計(jì)算機(jī)上使用

18、較高層次協(xié)議。在連接被關(guān)閉后,你不能再讀寫它。</p><p>  TCP和UDP之間的區(qū)別</p><p>  在你想要可靠的數(shù)據(jù)傳輸時(shí),TCP是最好的協(xié)議。UDP是高性能的無(wú)需連接的協(xié)議,但是它不保證可靠性。</p><p><b>  建立TCP客戶端</b></p><p>  注意:請(qǐng)參考最近的版本LabVIE

19、W幫助功能對(duì)這些指令和功能的細(xì)節(jié)描述。</p><p>  完成如下步驟使用TCP功能建立一個(gè)TCP顧客。</p><p>  用TCP的打開(kāi)連接功能來(lái)打開(kāi)一個(gè)服務(wù)器的連接。你必須規(guī)定服務(wù)器的因特網(wǎng)地址和服務(wù)器的端口。</p><p>  地址在網(wǎng)絡(luò)上識(shí)別計(jì)算機(jī)。遠(yuǎn)程端口在服務(wù)器使用聽(tīng)的計(jì)算機(jī)上識(shí)別一個(gè)通信通道。當(dāng)你建立一個(gè)TCP服務(wù)器時(shí),你要規(guī)定你想要服務(wù)器為通信

20、使用的端口。</p><p>  用TCP的寫功能把信息發(fā)送到服務(wù)器上。</p><p>  用TCP的讀功能來(lái)讀發(fā)自服務(wù)器的信息。你必須規(guī)定你想讀的字節(jié)數(shù)。</p><p>  用TCP的關(guān)閉功能來(lái)關(guān)閉與服務(wù)器的連接。</p><p>  請(qǐng)參閱labview\examples\comm\TCP.llb中對(duì)單一數(shù)據(jù)客戶端的TCP例程。<

21、;/p><p><b>  超時(shí)和差錯(cuò)</b></p><p>  當(dāng)你設(shè)計(jì)一種網(wǎng)絡(luò)應(yīng)用時(shí),應(yīng)細(xì)心考慮失敗是如何發(fā)生的。例如,如果服務(wù)器被毀,確定如何使每個(gè)客戶VI程序掌控它。</p><p>  一種解決方式是確保每個(gè)客戶VI程序有超時(shí)功能。如果發(fā)生沒(méi)能在一定量的時(shí)間之后生產(chǎn)結(jié)果,客戶端繼續(xù)執(zhí)行。在繼續(xù)時(shí),客戶端能試圖重建連接或者報(bào)告出錯(cuò)。如果必

22、要的話,客戶端VI程序能關(guān)閉應(yīng)用程序。</p><p><b>  建立TCP服務(wù)器</b></p><p>  注意:請(qǐng)參考最近的版本LabVIEW幫助功能對(duì)這些指令和功能的細(xì)節(jié)描述。</p><p>  完全如下步驟用TCP功能來(lái)建立一個(gè)TCP服務(wù)器。</p><p>  使用TCP聽(tīng)程序等待連接。你必須規(guī)定端口。這

23、個(gè)端口必須是客戶端試圖訪問(wèn)的同一個(gè)端口。</p><p>  如果連接被建立,用TCP讀功能從接受到信息的端口讀信息。</p><p>  用TCP寫功能返回結(jié)果。數(shù)據(jù)必須是一種客戶端能接受的形式。</p><p>  用TCP關(guān)連接功能來(lái)關(guān)閉連接。</p><p>  請(qǐng)參閱labview\examples\comm\TCP.llb中對(duì)單一

24、數(shù)據(jù)客戶端的TCP例程。</p><p><b>  TCP和UDP例子</b></p><p>  請(qǐng)參閱labview\examples\comm\TCP.llb和labview\examples\comm\UDP.llb中用TCP和UDP的VI程序和功能。</p><p>  Application Note 160</p>

25、<p>  Using LabVIEW? with TCP/IP and UDP</p><p>  Introduction</p><p>  Internet Protocol (IP), User Datagram Protocol (UDP), and Transmission Control Protocol (TCP) are basic tools for ne

26、twork communication. The name TCP/IP comes from two of the best-known protocols of the Internet protocol suite, the Transmission Control Protocol and the Internet Protocol.</p><p>  You can use TCP/IP to com

27、municate over single networks or interconnected networks. The individual networks can be separated by large geographical distances. TCP/IP routes data from one network or Internet-connected computer to another. Because T

28、CP/IP is available on most computers, it can transfer information among diverse systems.</p><p>  LabVIEW and TCP/IP</p><p>  You can use the TCP/IP protocols with LabVIEW on all platforms. LabV

29、IEW includes TCP and UDP VIs and functions you can use to create client or server VIs.</p><p><b>  IP</b></p><p>  IP performs the low-level service of moving data between computers.

30、 IP packages data into components called datagrams. A datagram contains the data and a header that indicates the source and destination addresses. IP determines the correct path for the datagram to take across the networ

31、k or Internet and sends the data to the specified destination.</p><p>  IP cannot guarantee delivery. In fact, IP might deliver a single datagram more than once if the datagram is duplicated in transmission.

32、 Programs rarely use IP but use TCP or UDP instead.</p><p><b>  UDP</b></p><p>  UDP provides simple, low-level communication among processes on computers. Processes communicate by s

33、ending datagrams to a destination computer or port. A port is the location where you send data. IP handles the computer-to-computer delivery. After the datagram reaches the destination computer, UDP moves the datagram to

34、 its destination port. If the destination port is not open, UDP discards the datagram. UDP shares the same delivery problems of IP.</p><p>  Use UDP in applications in which reliability is not critical. For

35、example, an application might transmit informative data to a destination frequently enough that a few lost segments of data are not problematic.</p><p>  LabVIEW?, National Instruments?, and ni.com? are trad

36、emarks of National Instruments Corporation. Product and company names mentioned herein are trademarks or trade names of their respective companies. For patents covering National Instruments products, refer to the appropr

37、iate location: Help»Patents in your software, the</p><p>  patents.txt file on your CD, or ni.com/patents.</p><p>  342028C-01© 2000–2004 National Instruments Corporation. All rights

38、reserved.March 2004</p><p>  Application Note 160</p><p><b>  2</b></p><p><b>  ni.com</b></p><p>  Using UDP in LabVIEW</p><p>  

39、Because UDP is not a connection-based protocol such as TCP, you do not need to establish a connection with a destination before you send or receive data. Instead, you specify the destination for the data when you send ea

40、ch datagram. Operating systems do not report transmission errors.</p><p>  Use the UDP Open function to open a UDP socket on a port. The number of simultaneously open UDP ports depends on the operating syste

41、m. The UDP Open function returns a network connection refnum that uniquely identifies the UDP socket. Use this connection refnum to refer to this socket in subsequent VI calls.</p><p>  Use the UDP Write fun

42、ction to send data to a destination, and use the UDP Read function to read that data. Each write operation requires a destination address and port. Each read operation contains the source address and port. UDP preserves

43、the datagram bytes that you specified for each command you send.</p><p>  In theory, you can send datagrams of any size. However, you typically would not use UDP to send large datagrams because it is not as

44、reliable as TCP.</p><p>  When you finish all communications on a port, use the UDP Close function to free system resources.</p><p>  UDP Multicast</p><p>  You can use the UDP func

45、tions to communicate to a single client (single-cast) or to all computers on the subnet through a broadcast. If you want to communicate to multiple specific computers, you must configure the UDP functions to iterate thro

46、ugh a list of clients. Using this technique creates duplicate network traffic because LabVIEW sends a separate copy of the data to each client and maintains a list of clients interested in receiving the data.</p>

47、<p>  Use multicasting to communicate between a single sender and multiple clients on a network without requiring the sender to maintain a list of clients or send multiple copies of the data to each client. To recei

48、ve data broadcast by a multicast sender, all clients must join a multicast group. The sender does not have to join a group to send data. The sender specifies a multicast IP address, which defines a multicast group. Multi

49、cast IP addresses are in the 224.0.0.0 to 239.255.255.255 range. When a</p><p>  To multicast in LabVIEW, use the UDP Multicast Open VI to open connections capable of reading, writing, or reading and writing

50、 UDP data. Specify the time-to-live (TTL) for writing data, the multicast address for reading data, and the multicast port number for reading and writing data. The default TTL is 1, which means LabVIEW sends the datagram

51、 only to the local subnet. When a router receives a multicast datagram, it decrements the datagram TTL. If the TTL is greater than 1, the router forwards </p><p>  If you specify a value greater than 1, the

52、datagram is sent and routers forward it through TTL-1 layers.</p><p>  Refer to the UDP Multicast Receiver VI and the UDP Multicast Sender VI in the labview\examples\comm\UDP.llb for examples of using UDP mu

53、lticasting.</p><p>  © National Instruments Corporation3Application Note 160</p><p><b>  TCP</b></p><p>  TCP ensures reliable transmission across networks, deliv

54、ering data in sequence without errors, loss, or duplication. TCP retransmits the datagram until it receives an acknowledgment.</p><p>  System Requirements</p><p>  Before using TCP/IP, confirm

55、that you have the necessary requirements, which vary depending on the platform you use.</p><p>  (Windows and UNIX) TCP/IP is built in. You do not need to use a third-party product to communicate using TCP/I

56、P. If your network is configured properly, LabVIEW requires no additional setup.</p><p>  (Mac OS) LabVIEW networking requires Open Transport, included in Mac OS 7.5 and later.</p><p>  Using TC

57、P in LabVIEW</p><p>  TCP is a connection-based protocol, which means that sites must establish a connection before transferring data. TCP permits multiple, simultaneous connections.</p><p>  Yo

58、u initiate a connection by waiting for an incoming connection or by actively seeking a connection with a specified address. In establishing TCP connections, you have to specify the address and a port at that address. A n

59、umber between 0 and 65,535 represents a port. UNIX reserves port numbers less than 1,024 for privileged applications. Different ports at a given address identify different services at that address.</p><p>  

60、Use the TCP Open Connection function to actively establish a connection with a specific address and port. If the connection is successful, the function returns a network connection refnum that uniquely identifies that co

61、nnection. Use this connection refnum to refer to the connection in subsequent VI calls.</p><p>  You can use the following techniques to wait for an incoming connection:</p><p>  Use the TCP Lis

62、ten VI to create a listener and wait for an accepted TCP connection at a specified port. If the connection is successful, the VI returns a connection refnum, the address, and the port of the remote TCP client.</p>

63、<p>  Use the TCP Create Listener function to create a listener and use the TCP Wait on Listener function to listen for and accept new connections. The TCP Wait on Listener function returns the same listener ID you

64、 wired to the function and the connection refnum for a connection. When you finish waiting for new connections, use the TCP Close Connection function to close a listener. You cannot read from or write to a listener.</

65、p><p>  The advantage of using the second technique is that you can use the TCP Close Connection function to cancel a listen operation, which is useful when you want to listen for a connection without using a t

66、imeout, but you want to cancel the listen when another condition becomes true. You can close the listen VI at any time.</p><p>  When you establish a connection, use the TCP Read function and the TCP Write f

67、unction to read and write data to the remote application.</p><p>  Use the TCP Close Connection function to close the connection to the remote application. If unread data remains and the connection closes, y

68、ou might lose data. Use a higher level protocol for your computer to determine when to close the connection. After a connection is closed, you cannot read from it or write to it again.</p><p>  Deciding betw

69、een TCP and UDP</p><p>  TCP is the best protocol to use if you want reliable data transmission. UDP is a connectionless protocol with higher performance, but it does not ensure reliable data transmission.&l

70、t;/p><p>  Creating a TCP Client</p><p>  Note Refer to the LabVIEW Help for the most recent version of these instructions and details for each of the functions.</p><p>  Complete the

71、following steps to create a TCP client using the TCP functions.</p><p>  1. Use the TCP Open Connection function to open a connection to a server. You must specify the Internet address of the server and the

72、port for the server.</p><p>  The address identifies a computer on the network. The remote port identifies a communication channel on the computer that the server uses to listen for communication requests. W

73、hen you create a TCP server, you specify the port that you want the server to use for communication.</p><p>  2. Use the TCP Write function to send a message to a server.</p><p>  3. Use the TCP

74、 Read function to read a message from the server. You must specify the number of bytes you want to read.</p><p>  4. Use the TCP Close Connection function to close the connection to the server.</p>&l

75、t;p>  Refer to the Simple Data Client VI in the labview\examples\comm\TCP.llb for an example of a TCP client.</p><p>  Timeouts and Errors</p><p>  When you design a network application, cons

76、ider carefully what should happen if something fails. For example, if the server crashes, determine how each client VI handles it.</p><p>  One solution is to make sure that each client VI has a timeout. If

77、something fails to produce results after a certain amount of time, the client continues execution. In continuing, the client can try to reestablish the connection or report the error. If necessary, the client VI can shut

78、 down the application.</p><p>  Creating a TCP Server</p><p>  Note Refer to the LabVIEW Help for the most recent version of these instructions and details for each of the functions.</p>

79、<p>  Complete the following steps to create a TCP server using the TCP functions.</p><p>  1. Use the TCP Listen VI to wait for a connection. You must specify the port. This port must be the same port

80、that the client attempts to access.</p><p>  2. If a connection is established, use the TCP Read function to read from that port to retrieve a message. 3. Use the TCP Write function to return results. The da

81、ta must be in a form that the client can accept. 4. Use the TCP Close Connection function to close the connection.</p><p>  Refer to the Simple Data Server VI in the labview\examples\comm\TCP.llb for an exam

82、ple of a TCP server.</p><p>  TCP and UDP Examples</p><p>  Refer to the labview\examples\comm\TCP.llb and the labview\examples\comm\UDP.llb for examples of using the TCP and UDP VIs and functio

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 眾賞文庫(kù)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論