BSD Sockets Interface Programmer's Guide
94 Chapter 4
Using Internet Datagram Sockets
Writing the Server and Client Processes
Function result: 0 if bind is successful, –1 if failure occurs.
Example:
struct sockaddr_in myaddr;
...
bind (s, &myaddr, sizeof(struct sockaddr_in));
When to Bind Socket Addresses
The client and server process should bind socket addresses after the
socket is created and before any other BSD Sockets system calls. Refer to
the bind(2) man page for more information on bind.
Parameter Description of Contents INPUT Value
s socket descriptor of local
socket
socket descriptor of
socket to be bound
addr socket address pointer to address to be
bound to s
addrlen length of socket address size of struct
sockaddr_in_address