HP Rp7410 BSD Sockets Interface Programmer's Guide - Page 93
Binding Socket Addresses to Datagram, Sockets
View all HP Rp7410 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 93 highlights
Using Internet Datagram Sockets Writing the Server and Client Processes When to Create Sockets The server or client process should create a socket before any other BSD Sockets system calls. Refer to the socket(2) man page for more information on socket. Binding Socket Addresses to Datagram Sockets After each process has created a socket, it must call bind to bind a socket address. Until an address is bound, other processes have no way to reference it. The server process must bind a specific port address to its socket. Otherwise, a client process would not know what port to send requests to for the desired service. The client process can let the local host bind its local port address. The client does not need to know its own port address, and if the server process needs to send a reply to the client's request, the server can find out the client's port address when it receives with recvfrom. Set up the address structure with a local address before you make a bind call. Use the wildcard address so your processes do not have to look up their own internet addresses. bind and its parameters are described in the following table. Include files: System call: #include #include #include bind (s, addr, addrlen) int s; struct sockaddr *addr; int addrlen; Chapter 4 93