First page Back Continue Last page Summary Graphics
Revisiting bind contd.
int bind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen);
Servers usually bind a well-known port, while clients leave the kernel to choose an ephemeral port.
A process can bind a specific IP address (must belong to an interface of the host):
- For a TCP client specifies the IP source for packets sent from that socket
- For a TCP server it restricts the socket to receive incoming client connection destined only to that IP address
It is normally necessary to assign a local address using bind before a SOCK_STREAM socket may receive connections.