DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

listen(SSC-osr5)


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-osr5), a backlog for incoming connections is specified with listen( ), and then the connections are accepted with accept(SSC-osr5). 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-osr5), connect(SSC-osr5), socket(SSC-osr5)
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005