1LISTEN(3P)                 POSIX Programmer's Manual                LISTEN(3P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10
11

NAME

13       listen — listen for socket connections and limit the queue of  incoming
14       connections
15

SYNOPSIS

17       #include <sys/socket.h>
18
19       int listen(int socket, int backlog);
20

DESCRIPTION

22       The listen() function shall mark a connection-mode socket, specified by
23       the socket argument, as accepting connections.
24
25       The backlog argument provides a hint to the  implementation  which  the
26       implementation shall use to limit the number of outstanding connections
27       in the socket's listen queue. Implementations may  impose  a  limit  on
28       backlog  and  silently  reduce  the specified value. Normally, a larger
29       backlog argument value shall result in a larger or equal length of  the
30       listen  queue.  Implementations  shall  support values of backlog up to
31       SOMAXCONN, defined in <sys/socket.h>.
32
33       The implementation may include incomplete  connections  in  its  listen
34       queue. The limits on the number of incomplete connections and completed
35       connections queued may be different.
36
37       The implementation may have an upper limit on the length of the  listen
38       queue—either  global  or  per accepting socket. If backlog exceeds this
39       limit, the length of the listen queue is set to the limit.
40
41       If listen() is called with a backlog argument value that is  less  than
42       0,  the  function behaves as if it had been called with a backlog argu‐
43       ment value of 0.
44
45       A backlog argument of 0 may allow the socket to accept connections,  in
46       which  case the length of the listen queue may be set to an implementa‐
47       tion-defined minimum value.
48
49       The socket in use may require the process to  have  appropriate  privi‐
50       leges to use the listen() function.
51

RETURN VALUE

53       Upon  successful  completions,  listen()  shall return 0; otherwise, −1
54       shall be returned and errno set to indicate the error.
55

ERRORS

57       The listen() function shall fail if:
58
59       EBADF  The socket argument is not a valid file descriptor.
60
61       EDESTADDRREQ
62              The socket is not bound to a local  address,  and  the  protocol
63              does not support listening on an unbound socket.
64
65       EINVAL The socket is already connected.
66
67       ENOTSOCK
68              The socket argument does not refer to a socket.
69
70       EOPNOTSUPP
71              The socket protocol does not support listen().
72
73       The listen() function may fail if:
74
75       EACCES The calling process does not have appropriate privileges.
76
77       EINVAL The socket has been shut down.
78
79       ENOBUFS
80              Insufficient  resources  are available in the system to complete
81              the call.
82
83       The following sections are informative.
84

EXAMPLES

86       None.
87

APPLICATION USAGE

89       None.
90

RATIONALE

92       None.
93

FUTURE DIRECTIONS

95       None.
96

SEE ALSO

98       accept(), connect(), socket()
99
100       The Base Definitions volume of POSIX.1‐2008, <sys_socket.h>
101
103       Portions of this text are reprinted and reproduced in  electronic  form
104       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
105       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
106       Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
107       cal and Electronics Engineers,  Inc  and  The  Open  Group.   (This  is
108       POSIX.1-2008  with  the  2013  Technical Corrigendum 1 applied.) In the
109       event of any discrepancy between this version and the original IEEE and
110       The  Open Group Standard, the original IEEE and The Open Group Standard
111       is the referee document. The original Standard can be  obtained  online
112       at http://www.unix.org/online.html .
113
114       Any  typographical  or  formatting  errors that appear in this page are
115       most likely to have been introduced during the conversion of the source
116       files  to  man page format. To report such errors, see https://www.ker
117       nel.org/doc/man-pages/reporting_bugs.html .
118
119
120
121IEEE/The Open Group                  2013                           LISTEN(3P)
Impressum