HP Rp7410 BSD Sockets Interface Programmer's Guide - Page 37
Setting Up the Server to Wait for Connection, Requests
View all HP Rp7410 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 37 highlights
Using Internet Stream Sockets Writing the Server Process Example: struct sockaddr_in myaddr; ... bind (ls, &myaddr, sizeof(struct sockaddr_in)); When to Bind Socket Addresses The server process should bind the socket address 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. Setting Up the Server to Wait for Connection Requests Once your server process has an address bound to it, it must call listen to set up a queue that accepts incoming connection requests. The server process then monitors the queue for requests (using select(2) or accept ). The server process cannot respond to a connection request until it has executed listen. listen and its parameters are described in the following table. Include files: none System call: listen(s, backlog) int s, backlog; Parameter Description of Contents INPUT Value s backlog socket descriptor of local socket preferred maximum number of connection requests in the queue at any time server socket's descriptor size of queue (between 0 and SOMAXCONN) Function result: 0 if listen is successful, -1 if failure occurs. Example: listen (ls, 5); Chapter 2 37