Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 14

Lesson 5

Serving Data to a Client Using TCP/IP

TOPICS
A. TCP/IP Overview
B. Implementing the Client/Server Model

ni.com/training
A. TCP/IP Overview
• Link two Ethernet devices together using a
crossover cable
• Link many devices together using a hub
• Communicate using IP address

PC 128.1.0.0

X.X.X.X

Ethernet Device N N N

ni.com/training
The Client/Server Model

Server Client

Service Provider Service Requestor

ni.com/training
Client Model Overview
NO
Open Execute
Connection Command Done?
To Server on Server
YES

Close
Connection
To Server

ni.com/training
Server Model Overview (Handles one client)
Initialize Wait for a
Server Connection
Wait for a
Command
NO

Return Execute
Done?
Results Command
YES

Close
Connection

ni.com/training
Exercise 5-1: Simple Data Client VI and
Simple Data Server VI

Concept
Open and examine two of the TCP/IP example VIs that
GOAL

show how you can use LabVIEW as a TCP client and


TCP server.

ni.com/training
B. Implementing the Client/Server Model
NO
Open Execute
Connection Command Done?
To Server on Server
YES

Close
Connection
To Server

ni.com/training
Server Model VIs
Initialize Wait for a
Server Connection
Wait for a
Command
NO

Return Execute
Done?
Command Command
YES

Close
Connection

ni.com/training
Server Model VIs

• TCP Listen combines both VIs into a high-level easy to use VI


• Creates a listener and waits for an accepted TCP network
connection

ni.com/training
Server Model (Handles multiple clients)

ni.com/training
Client/Server VIs
Read Modes:
Execute
Command • Standard (default): Returns bytes
Client or Server requested or more; timeout error if
less than requested are received
• Buffered: Returns bytes requested
or none; timeout error if less than
requested are received
• CRLF: Returns bytes read up to
and including carriage return and
line feed; timeout error if not found
• Immediate: Returns any bytes

ni.com/training
Client/Server VIs
Close
Connection

ni.com/training
Exercise 5-2: TCP File Transfer

Concept
Create a file transfer program using TCP
GOAL

ni.com/training
Summary

• The client/server model is commonly used for networked


communication
• A client application initiates the connection and instructs
the server to read and/or write data
• A server application waits for a connection and then reads
or writes data as instructed by the client

ni.com/training

You might also like