Using UNIX Domain Datagram Sockets
Writing the Server and Client Processes
Writing the Server and Client Processes
This section discusses the calls your server and client processes must
make.
Creating Sockets
Both processes must call socket to create communication endpoints.
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) if successful, -1
if socket call fails.
Example:
#include <sys/type.h>
#include <sys/socket.h>
...
s = socket(AF_UNIX, SOCK_DGRAM, 0)
When to Create Sockets
The server or client process should create sockets before any other BSD
Sockets system calls. Refer to the socket(2) man page for more
information on socket.
152
INPUT Value
AF_UNIX
SOCK_DGRAM
0 (default)
Chapter 7