DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Developing applications over TCP/IP using Internet sockets

The server (Internet domain)

A completed connection is identified by a unique pair of sockets, each socket being an endpoint associated with one of the reciprocating processes. For the server to receive a client's connection, the server must issue two system calls after binding its socket. The first is to indicate a willingness to listen for incoming connection requests. The second is to accept the client's connect.

Consider this example:

listen(s,5);

The second parameter, 5, indicates the maximum number of outstanding connections which can be queued awaiting the acceptance of the server. This limit prevents processes from tying up system resources. Should a connection be requested while the queue is full, the server does not refuse the connection, but ignores the messages which comprise the request. This forces the client to retry the connection request and gives the server time to make room in its queue. The listen call itself does not make the server process wait; it only specifies the maximum number of outstanding connection requests that can be queued.

Had the connection been returned with the ECONNREFUSED error, the client would be unable to tell if the server was up or not. See ``Connection errors (Internet domain)'' for the list of errors. As it is, now it is still possible to get the ETIMEDOUT error back, though this is unlikely. The backlog figure supplied with the listen call is limited by the system to a maximum of five pending connections on any one queue. This avoids the problem of processes tying up system resources by setting an infinite backlog and then ignoring all connection requests.


Next topic: Using wildcards in socket addresses (Internet domain only)
Previous topic: Making a connection (Internet domain)

© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003