Open System Services System Calls Reference Manual (G06.25+, H06.03+)

System Functions (s and S) socket(2)
NAME
socket - Creates an endpoint for communications
LIBRARY
G-series native OSS processes: system library
H-series OSS processes: implicit libraries
SYNOPSIS
#include <sys/socket.h>
int socket(
int domain,
int type,
int protocol
);
PARAMETERS
domain Species the address family of the communications domain in which the socket
is to be created.
type Species the type of socket to be created.
protocol Species a particular protocol to be used with the created socket. Specifying a
protocol of 0 (zero) causes the socket() function to default to the typical proto-
col used for the requested socket type. If a nonzero value is specied for proto-
col, it must specify a protocol that is supported by the address family specied
by the domain parameter.
DESCRIPTION
The socket() function creates an unbound socket in a specied communications domain and
returns a le descriptor for the socket that can be used in later function calls that operate on sock-
ets.
The domain parameter species the address family used in the communications domain. The
address families supported are:
AF_INET IPv4 Internet addresses. The value PF_INET can also be used to specify this
address family.
AF_INET6 IPv6 Internet addresses. The value PF_INET6 can also be used to specify this
address family.
AF_UNIX UNIX pathnames. The values PF_UNIX, AF_LOCAL, and PF_LOCAL can
also be used to specify this address family.
The type parameter species the socket type, which determines the semantics of communications
over the socket. The socket types supported are:
SOCK_DGRAM
Provides datagrams, which are connectionless, unreliable messages of a xed
maximum length.
SOCK_STREAM
Provides sequenced, reliable, two-way, connection-oriented byte streams with a
transmission mechanism for out-of-band data.
The documentation for specic address families species which socket types each family sup-
ports. The sys/socket.h header le contains denitions for socket domains, types, and protocols.
527186-003 Hewlett-Packard Company 771