Writing The Client Process; Creating A Socket - 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

Writing the Client Process

This section discusses the calls your client process must make to connect
with and be served by a server process.

Creating a Socket

The client process must call socket to create a communication endpoint.
socket and its parameters are described in the following table.
Include files:
#include <sys/types.h>
#include <sys/socket.h>
System call:
s = socket(af, type, protocol)
int af, type, protocol;
Parameter
Description of Contents
af
address family
type
socket type
protocol
underlying protocol to be
used
Function result: socket number (HP-UX file descriptor), –1 if failure
occurs.
Example:
s = socket (AF_UNIX, SOCK_STREAM, 0);
The socket number returned is the socket descriptor for the newly
created socket. This number is an HP-UX file descriptor and can be used
for reading, writing or any standard file system calls after a BSD Sockets
connection is established. A socket descriptor is treated like a file
descriptor for an open file.
When to Create Sockets
The client process should create sockets before requesting a connection.
Refer to the socket(2) man page for more information on socket.
Chapter 6
Using UNIX Domain Stream Sockets
Writing the Client Process
INPUT Value
AF_UNIX
SOCK_STREAM
0 (default)
133

Advertisement

Table of Contents
loading

Table of Contents