struct sockaddr { uint32_t sun_family; // AF values of socket(). char data[]; }; int bind(int sockfd, const struct sockaddr *addr, unsigned int addrlen);
This syscall assigns a global address to the passed socket, the meaning and nature of the address depends on the passed socket.
The actual structure passed for the addr
argument will depend on
the address family, sockaddr
is a catch-all placeholder value.
The syscall returns 0
on success or -1
on failure, with the
following errno:
EINVAL
: Invalid address, may be already in use.
EFAULT
: Bad memory address.
EBADFD
: The passed FD is not a socket.