HP Rp7410 BSD Sockets Interface Programmer's Guide - Page 38
Accepting a Connection
View all HP Rp7410 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 38 highlights
Using Internet Stream Sockets Writing the Server Process backlog is the preferred number of unaccepted incoming connections allowed at a given time. The actual number may be greater than the specified backlog. When the request is full, further connection requests are rejected. A backlog of 0 specifies only 1 pending connection can exist at any given time. SOMAXCONN is defined in . The default setting is 20. When to Set Up Server to Listen The server process should be set up to listen after socket is created and bound and before the server can respond to connection requests. Refer to the listen(2) man page for more information on listen. Accepting a Connection The server process can accept any connection requests that enter its queue after it executes listen. accept creates a new socket for the connection and returns the socket descriptor for the new socket. The new socket: • Is created with the same properties as the old socket. • Has the same bound port address as the old socket. • Is connected to the client process's socket. accept blocks until there is a connection request from a client process in the queue, unless you are using nonblocking I/O. accept and its parameters are described in the following table. Include files: System call: #include #include #include s = accept(ls,addr,addrlen) int s; int ls; struct sockaddr *addr; int *addrlen; 38 Chapter 2