bind a name to a socket
#include <sys/types.h> #include <sys/socket.h> int bind( int s, const struct sockaddr *name, int namelen );
When a socket is created with socket(), it exists in a namespace (address family) but has no name assigned to it. The bind() function assigns a name to that unnamed socket.
The bind() function assigns a local address. Use connect() to assign a remote address. |
The rules used for binding names vary between communication domains.
If an error occurred, errno could contain one of the following:
POSIX 1003.1g (draft)
Safety: | |
---|---|
Interrupt handler | No |
Signal handler | No |
Thread | Yes |
ICMP, IP, TCP, and UDP protocols, connect(), getsockname(), listen(), socket()