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 Specifies the address family of the communications domain in which the socket
is to be created.
type Specifies the type of socket to be created.
protocol Specifies 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 specified for proto-
col, it must specify a protocol that is supported by the address family specified
by the domain parameter.
DESCRIPTION
The socket() function creates an unbound socket in a specified communications domain and
returns a file descriptor for the socket that can be used in later function calls that operate on sock-
ets.
The domain parameter specifies 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 specifies 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 fixed
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 specific address families specifies which socket types each family sup-
ports. The sys/socket.h header file contains definitions for socket domains, types, and protocols.
527186-003 Hewlett-Packard Company 7−71