Assign a local protocol address to a socket.
#include <sys/types.h> #include <sys/socket.h> int bind(int s, const struct sockaddr *addr, socklen_t addrlen);
The bind() system call assigns the local protocol address to a socket. When a socket is created with socket it exists in an address family space but has no protocol address assigned. The bind() system call requests that addr be assigned to the socket.
For maximum portability, you should always zero the socket address structure before populating it and passing it to bind().
0
(zero)
-1
EAGAIN |
Kernel resources to complete the request are temporarily unavailable. |
EBADF |
The s argument is not a valid descriptor. |
ENOTSOCK |
The s argument is not a socket. |
EADDRNOTAVAIL |
The specified address is not available from the local machine. |
EADDRINUSE |
The specified address is already in use. |
EACCES |
The requested address is protected, and the current user has inadequate permission to access it. |
EFAULT |
The addr argument is not in a valid part of the user address space. |
Versions | Link to |
---|---|
INtime 4.0 | netlib.lib |