listen(2) System Calls Manual listen(2) listen - LIBRARY Standard C library (libc, -lc) #include int listen(int sockfd, int backlog); listen() , sockfd , , accept(2). sockfd , SOCK_STREAM SOCK_SEQPACKET. backlog , sockfd. , , ECONNREFUSED , , , . On success, zero is returned. On error, -1 is returned, and errno is set to indicate the error. EADDRINUSE . EADDRINUSE ( ) , sockfd, , , . /proc/sys/net/ipv4/ip_local_port_range ip(7). EBADF sockfd . ENOTSOCK sockfd . EOPNOTSUPP listen(). POSIX.1-2008. POSIX.1-2001, 4.4BSD (first appeared in 4.2BSD). : (1) socket(2). (2) bind(2) , connect(2). (3) listen(). (4) accept(2). backlog TCP- Linux 2.2. (completely) , , . /proc/sys/net/ipv4/tcp_max_syn_backlog. syncookies, . . tcp(7). If the backlog argument is greater than the value in /proc/sys/net/core/somaxconn, then it is silently capped to that value. Since Linux 5.4, the default in this file is 4096; in earlier kernels, the default value is 128. Before Linux 2.4.25, this limit was a hard coded value, SOMAXCONN, with the value 128. . bind(2). . accept(2), bind(2), connect(2), socket(2), socket(7) Artyom Kunyov , Azamat Hackimov , Dmitry Bolkhovskikh , Katrin Kutepova , Konstantin Shvaykovskiy , Yuri Kozlov ; GNU 3 , . . , , . Linux man-pages 6.06 31 2023 . listen(2)