DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

listen(SSC)


listen -- listen for connections on a socket

Synopsis

cc [options] file -lsocket -lnsl
#include <sys/socket.h>

int listen(int socket, int backlog);

Description

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

If the inconfig(ADMN) parameter tcp_q0limit is set to 0, the backlog parameter defines the maximum length to which the queues of pending (3-way handshake incomplete) and established (3-way handshake complete) connections may grow. A connection request is silently dropped if it arrives when the pending queue is full.

If the value of tcp_q0limit is greater than 0, it determines the maximum length of the pending connection queue. If a connection request arrives when the queue is full, an existing pending connection is dropped at random (RST is sent to the peer) and the new request is placed on the queue. In this case, the backlog parameter defines only the maximum length to which the established connection queue may grow.

If the value of backlog is less than 0, the length of the socket's listen queue (or queues) is set to 0.

Files

/usr/lib/locale/locale/LC_MESSAGES/uxnsl

Return values

A value of 0 indicates success; -1 indicates an error.

Errors

The call fails if:

EBADF
socket is not a valid descriptor.

ENOTSOCK
socket is not a socket.

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

EINVAL
The socket is already connected or has been shut down.

EDESTADDRREQ
The socket is not bound to a local address, and the protocol does not support listening on an unbound socket.

ENOBUFS
System resources are insufficient to complete the call.

References

accept(SSC), connect(SSC), inconfig(ADMN), socket(SSC)
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 - 01 June 2005