LISTEN(3)                  POSIX Programmer's Manual                 LISTEN(3)



PPRROOLLOOGG
       This manual page is part of the POSIX Programmer's Manual.  The OS
       implementation of this interface may differ (consult the corresponding
       OS manual page for details of OS behavior), or the interface may not be
       implemented on OS.

NNAAMMEE
       listen -- listen for socket connections and limit the queue of incoming
       connections

SSYYNNOOPPSSIISS
       #include <sys/socket.h>

       int listen(int _s_o_c_k_e_t, int _b_a_c_k_l_o_g);

DDEESSCCRRIIPPTTIIOONN
       The _l_i_s_t_e_n() function shall mark a connection-mode socket, specified by
       the _s_o_c_k_e_t argument, as accepting connections.

       The _b_a_c_k_l_o_g argument provides a hint to the implementation which the
       implementation shall use to limit the number of outstanding connections
       in the socket's listen queue. Implementations may impose a limit on
       _b_a_c_k_l_o_g and silently reduce the specified value. Normally, a larger
       _b_a_c_k_l_o_g argument value shall result in a larger or equal length of the
       listen queue. Implementations shall support values of _b_a_c_k_l_o_g up to
       SOMAXCONN, defined in _<_s_y_s_/_s_o_c_k_e_t_._h_>.

       The implementation may include incomplete connections in its listen
       queue. The limits on the number of incomplete connections and completed
       connections queued may be different.

       The implementation may have an upper limit on the length of the listen
       queue--either global or per accepting socket. If _b_a_c_k_l_o_g exceeds this
       limit, the length of the listen queue is set to the limit.

       If _l_i_s_t_e_n() is called with a _b_a_c_k_l_o_g argument value that is less than
       0, the function behaves as if it had been called with a _b_a_c_k_l_o_g
       argument value of 0.

       A _b_a_c_k_l_o_g argument of 0 may allow the socket to accept connections, in
       which case the length of the listen queue may be set to an
       implementation-defined minimum value.

       The socket in use may require the process to have appropriate
       privileges to use the _l_i_s_t_e_n() function.

RREETTUURRNN VVAALLUUEE
       Upon successful completions, _l_i_s_t_e_n() shall return 0; otherwise, -1
       shall be returned and _e_r_r_n_o set to indicate the error.

EERRRROORRSS
       The _l_i_s_t_e_n() function shall fail if:

       EEBBAADDFF  The _s_o_c_k_e_t argument is not a valid file descriptor.

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

       EEIINNVVAALL The _s_o_c_k_e_t is already connected.

       EENNOOTTSSOOCCKK
              The _s_o_c_k_e_t argument does not refer to a socket.

       EEOOPPNNOOTTSSUUPPPP
              The socket protocol does not support _l_i_s_t_e_n().

       The _l_i_s_t_e_n() function may fail if:

       EEAACCCCEESS The calling process does not have appropriate privileges.

       EEIINNVVAALL The _s_o_c_k_e_t has been shut down.

       EENNOOBBUUFFSS
              Insufficient resources are available in the system to complete
              the call.

       _T_h_e _f_o_l_l_o_w_i_n_g _s_e_c_t_i_o_n_s _a_r_e _i_n_f_o_r_m_a_t_i_v_e_.

EEXXAAMMPPLLEESS
       None.

AAPPPPLLIICCAATTIIOONN UUSSAAGGEE
       None.

RRAATTIIOONNAALLEE
       None.

FFUUTTUURREE DDIIRREECCTTIIOONNSS
       None.

SSEEEE AALLSSOO
       _a_c_c_e_p_t(), _c_o_n_n_e_c_t(), _s_o_c_k_e_t()

       The Base Definitions volume of POSIX.1-2017, <<ssyyss__ssoocckkeett..hh>>

CCOOPPYYRRIIGGHHTT
       Portions of this text are reprinted and reproduced in electronic form
       from IEEE Std 1003.1-2017, Standard for Information Technology --
       Portable Operating System Interface (POSIX), The Open Group Base
       Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the
       Institute of Electrical and Electronics Engineers, Inc and The Open
       Group.  In the event of any discrepancy between this version and the
       original IEEE and The Open Group Standard, the original IEEE and The
       Open Group Standard is the referee document. The original Standard can
       be obtained online at http://www.opengroup.org/unix/online.html .

       Any typographical or formatting errors that appear in this page are
       most likely to have been introduced during the conversion of the source
       files to man page format. To report such errors, see
       https://www.kernel.org/doc/man-pages/reporting_bugs.html .



IEEE/The Open Group                  2017                            LISTEN(3)
