Open System Services System Calls Reference Manual (G06.25+, H06.03+)
bind(2) OSS System Calls Reference Manual
NAME
bind - Binds a name to a socket
LIBRARY
G-series native OSS processes: system library
H-series OSS processes: implicit libraries
SYNOPSIS
#include <sys/socket.h>
int bind(
int socket,
const struct sockaddr *address,
size_t address_len
);
PARAMETERS
socket Specifies the file descriptor of the socket to be bound.
address Points to a sockaddr structure that contains the address to be bound to the
socket. The length and format of the address depend on the address family of the
socket.
For AF_INET sockets, a pointer to the address structure sockaddr_in must be
cast as a struct sockaddr.ForAF_INET6 sockets, a pointer to the address
structure sockaddr_in6 must be cast as a struct sockaddr.ForAF_UNIX sock-
ets, a pointer to the address structure sockaddr_un must be cast as a struct
sockaddr.
address_len Specifies the length of the sockaddr structure pointed to by the address parame-
ter.
DESCRIPTION
The bind( ) function assigns a name, which consists of an address stored in a sockaddr structure,
to an unnamed socket. Sockets created with the socket() function are initially unnamed; they are
identified only by their address family.
An application program can retrieve the assigned socket name with the getsockname( ) function.
RETURN VALUES
Upon successful completion, the bind() function returns the value 0 (zero). Otherwise, the
bind( ) function returns -1 and sets errno to indicate the error.
ERRORS
If any of the following conditions occurs, the bind() function sets errno to the corresponding
value:
[EACCES] One of the following conditions occurred:
• The specified address is protected and the current user does not have
permission to bind to it.
• The socket is an AF_UNIX socket and either a component of the path
prefix denies search permission, or the requested name requires writing
in a directory with a mode that denies write permission.
[EADDRINUSE]
The specified address is already in use.
1−8 Hewlett-Packard Company 527186-003