The Windows Sockets listen
function establishes a socket to listen for an incoming connection.
int listen (
[in] A descriptor identifying a bound, unconnected socket.
[in] The maximum length to which the queue of pending connections can GROW. If
this value is SOMAXCONN, then the underlying service provider responsible for
will set the backlog to a maximum "reasonable" value.
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
applies only to sockets that are connection oriented, for example, those of
type SOCK_STREAM. The socket s
is put into "passive'' mode where incoming connection requests are
acknowledged and queued pending acceptance by the process.
This function is typically used by servers that could have more than one
connection request at a time: if a connection request arrives with the queue full,
the client will receive an error with an indication of WSAECONNREFUSED.
attempts to continue to function rationally when there are no available
descriptors. It will accept connections until the queue is emptied. If descriptors
become available, a later call to listen
will refill the queue to the current or most recent "backlog'', if possible,
and resume listening for incoming connections.
An application can call listen
more than once on the same socket. This has the effect of updating the
current backlog for the listening socket. Should there be more pending connections
than the new backlog
value, the excess pending connections will be reset and dropped.
parameter is limited (silently) to a reasonable value as determined by the
underlying service provider. Illegal values are replaced by the nearest legal
If no error occurs, listen
returns zero. Otherwise, a value of SOCKET_ERROR is returned, and a specific
error code can be retrieved by calling WSAGetLastError
||A successful WSAStartup must occur before using this function.
||The network subsystem has failed.
||An attempt has been made to listen on an address in use.
||A blocking Windows Sockets 1.1 call is in progress, or the service provider is
still processing a callback function.
||The socket has not been bound with bind.
||The socket is already connected.
||No more socket descriptors are available.
||No buffer space is available.
||The descriptor is not a socket.
||The referenced socket is not of a type that supports the listen operation.
- Software for developers
Software for Android Developers
- More information resources
Unix Manual Pages
- Databases for Amazon shops developers
Amazon Categories Database
Browse Nodes Database