ProSoft Technology MVI69E-LDM User Manual

Page 48

Advertising
background image

Contents

MVI69E-LDM ♦ "C" Programmable

Developer's Manual

Linux Application Development Module

Page 48 of 130

ProSoft Technology, Inc.

August 21, 2014

To execute the sample:

1 Go to the default home directory

/psft/sample

.

2 Type the command

./Client_Sample

ip.address.of.server to run the program. The IP

address of the server node must be provided in order for the server to know which node
is executing the server program.

3 The client will send a connection request to the server, print the response from the

server to the console, and then exit.

Reviewing the source code for

Client_Sample

, you will see that the main program:

 registers

sigquit_handler

for four signals.

 checks command line and print usage message if required.
 opens the backplane using

open_backplane()

. See the detailed description in

backplane_sample

.

 creates a socket with a call to

socket()

.

 initializes the server address (serv_addr) structure:

o

indicates that an IP4 address is going to be used with

AF_INET

.

o

sets the destination port is the well known port

SERVER_PORT_NUMBER

.

o

converts the string version of the server IP address to binary with

inet_pton()

.

connect()

is called to create the TCP connection to the server.

 When the sockets are connected, the server sends the date and time from the server as

a message back to the clients. The client then uses the

read()

function to receive the

buffer of data and prints the contents to the console.
























Advertising