HP Rp7410 BSD Sockets Interface Programmer's Guide - Page 129
socket descriptor of local
![]() |
View all HP Rp7410 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 129 highlights
Using UNIX Domain Stream Sockets Writing the Server Process Binding a Socket Address to the Server Process's Socket After your server process has created a socket, it must call bind to bind a socket address. Until an address is bound to the server socket, other processes have no way to reference it. The server process must bind a specific pathname to this socket, which is used for listening. Otherwise, a client process would not know what pathname to connect to for the desired service. Set up the address structure with a local address before you make a bind call. 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_un *addr; int addrlen; Parameter s addr addrlen Description of Contents INPUT Value socket descriptor of local socket descriptor of socket socket to be bound socket address pointer to address to be bound to s length of socket address size of struct sockaddr_un Function result: 0 if bind is successful, -1 if failure occurs. Example: struct sockaddr_un myaddr; ... bind (ls, &myaddr, sizeof(struct sockaddr_un)); When to Bind Socket Addresses The 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. Chapter 6 129
![](/manual_guide/products/hewlettpackard-rp5405-bsd-sockets-interface-programmers-guide-5276e7d/129.png)