![]() |
![]() |
![]() |
Bind a name to a socket
#include <sys/types.h> #include <sys/socket.h> int bind( int s, const struct sockaddr * name, size_t namelen );
libsocket
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.
Arguments for bind():
![]() |
The bind() function assigns a local address. Use connect() to assign a remote address. |
The rules used for binding names vary between communication domains.
Standard Unix, POSIX 1003.1g (draft)
Safety: | |
---|---|
Cancellation point | Yes |
Interrupt handler | No |
Signal handler | No |
Thread | Yes |
ICMP, IP, TCP, and UDP protocols
connect(), getsockname(), listen(), socket()
![]() |
![]() |
![]() |