DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

listen(SSC)


listen -- listen for connections on a socket

Syntax

cc ... -lsocket

int listen (s, backlog)
int s, backlog;

Description

To accept connections, a socket is first created with socket(SSC), a backlog for incoming connections is specified with listen( ), and then the connections are accepted with accept(SSC). The listen( ) call applies only to sockets of type SOCK_STREAM.

The backlog parameter defines the maximum length to which the queue of pending connections may grow. If a connection request arrives with the queue full, the client receives an error with an indication of ECONNREFUSED.

Return values

A return value of zero indicates that the call succeeded. A return value of -1 indicates that an error occurred, and in this case an error code is stored in the global variable errno.

Diagnostics

The call fails if:

[EBADF]
The s argument is not a valid descriptor.

[ENOTSOCK]
The s argument does not point to a socket.

[EOPNOTSUPP]
The socket is not of a type that supports the listen( ) operation.

Limitations

The backlog is currently limited (silently) to 5.

See also

accept(SSC), connect(SSC), socket(SSC)
© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003