Use the bind
function to assign an address to a socket. The
prototype for bind
is in the header file `sys/socket.h'.
For examples of use, see section Example of Local-Namespace Sockets, or see section Internet Socket Example.
bind
function assigns an address to the socket
socket. The addr and length arguments specify the
address; the detailed format of the address depends on the namespace.
The first part of the address is always the format designator, which
specifies a namespace, and says that the address is in the format of
that namespace.
The return value is 0
on success and -1
on failure. The
following errno
error conditions are defined for this function:
EBADF
ENOTSOCK
EADDRNOTAVAIL
EADDRINUSE
EINVAL
EACCES
IPPORT_RESERVED
minus one; see
section Internet Ports.)
Additional conditions may be possible depending on the particular namespace of the socket.
Go to the first, previous, next, last section, table of contents.