Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
Berkeley Sockets/iX Reference Manual: HP 3000 MPE/iX Computer Systems > Chapter 2 Socket System Calls

LISTEN

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

C Interface

     listen(s, backlog)

     int s, backlog;

Description

To accept connections, a socket is first created with socket, a queue for incoming connections is specified with listen, and then connections are accepted with accept. The listen call applies only to unconnected sockets of type SOCK_STREAM. Note that you cannot call listen after accepthas been called. If the socket has not been bound to a local port before the listen is invoked, the system automatically binds a local port for the socket to listen on.

The listen queue is established for the socket specified by the s parameter, which is a socket descriptor.

The backlog parameter defines the maximum allowable length of the queue for pending connections. If a connection request arrives when the queue is full, the client receives an ETIMEDOUT error.

The backlog parameter is limited (silently) to be in the range of 1 to 128. If you specify any other value, the system automatically assigns the closest value within range.

Return Value

If the call is successful, 0 is returned. If the call fails, a -1 is returned, and an error code is stored in errno.

Errors

The following errors are returned by listen:

[EBADF]

The argument s is not a valid descriptor.

[EDESTADDRREQ]

No bind address was established.

[ENOTSOCK]

The argument s is not a socket.

[EOPNOTSUPP]

The socket is not of a type that supports the listen operation.

[ENOBUFS]

Series 300 only: No buffer space is available. The listen call cannot be started at this time.

[EINVAL]

The socket has been shut down or is already connected.

MPE/iX Specific

The backlog limit on MPE/iX is 128 as opposed to the backlog limit of 20 on HP-UX. When an HP-UX socket has performed a listen, the incoming connection requests are completed as they are received (up to the backlog limit). When using MPE/iX, connections are completed by the call to accept.

Author

UCB (University of California at Berkeley)

See Also

accept, connect, socket

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© Hewlett-Packard Development Company, L.P.