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

NAME

6       listen  - listen for socket connections and limit the queue of incoming
7       connections
8

SYNOPSIS

10       #include <sys/socket.h>
11
12       int listen(int socket, int backlog);
13
14

DESCRIPTION

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

RETURN VALUE

47       Upon successful completions, listen() shall  return  0;  otherwise,  -1
48       shall be returned and errno set to indicate the error.
49

ERRORS

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

EXAMPLES

83       None.
84

APPLICATION USAGE

86       None.
87

RATIONALE

89       None.
90

FUTURE DIRECTIONS

92       None.
93

SEE ALSO

95       accept()  ,  connect()  ,  socket()  ,  the  Base Definitions volume of
96       IEEE Std 1003.1-2001, <sys/socket.h>
97
99       Portions of this text are reprinted and reproduced in  electronic  form
100       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
101       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
102       Specifications  Issue  6,  Copyright  (C) 2001-2003 by the Institute of
103       Electrical and Electronics Engineers, Inc and The Open  Group.  In  the
104       event of any discrepancy between this version and the original IEEE and
105       The Open Group Standard, the original IEEE and The Open Group  Standard
106       is  the  referee document. The original Standard can be obtained online
107       at http://www.opengroup.org/unix/online.html .
108
109
110
111IEEE/The Open Group                  2003                            LISTEN(P)
Impressum