Example Using Internet Stream Sockets - HP Rp3440-4 - 9000 - 0 MB RAM Programmer's Manual

Bsd sockets interface programmer’s guide
Hide thumbs Also See for Rp3440-4 - 9000 - 0 MB RAM:
Table of Contents

Advertisement

Using Internet Stream Sockets

Example Using Internet Stream Sockets

Example Using Internet Stream Sockets
NOTE
These programs are provided as examples only of stream socket usage
and are not Hewlett-Packard supported products.
These program examples demonstrate how to set up and use internet
stream sockets. These sample programs are in the
/usr/lib/demos/networking/socket directory. The client program
is intended to run in conjunction with the server program. The client
program requests a service called example from the server program.
The server process receives requests from the remote client process,
handles the request and returns the results to the client process. Note
that the server:
• Uses the wildcard address for the listen socket.
• Uses the ntohs address conversion call to show porting to a host that
• Uses the SO_LINGER option for a graceful disconnect.
The client process creates a connection, sends requests to the server
process and receives the results from the server process. Note that the
client:
• Uses shutdown to indicate that it is done sending requests.
• Uses getsockname to see what socket address was assigned to the
• Uses the ntohs address conversion call to show porting to a host that
Before you run the example programs, make the following entry in the
two host's /etc/services files:
example
The source code for these two programs follows
/*
*
*
* This is an example program that demonstrates the use of stream
* sockets as a BSD Sockets mechanism.
* and is intended to operate in conjunction with the client
* program found in client.tcp.
48
requires it.
local socket by the host.
requires it.
22375/tcp
S E R V . T C P
This contains the server,
Together, these two programs
Chapter 2

Advertisement

Table of Contents
loading

Table of Contents