.\" Copyright (c) 1983, 1991 The Regents of the University of California. .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" $Id: listen.2,v 1.3 2005/02/21 16:25:16 pepin.jimenez Exp $ .\" .\" Modified Fri Jul 23 22:07:54 1993 by Rik Faith .\" Modified Mon Aug 19 10:07:54 1993 by Martin Schulze (joey@debian.org) .\" Modified 950727 by aeb, following a suggestion by Urs Thuermann .\" .\" Modified Tue Oct 22 08:11:14 EDT 1996 by Eric S. Raymond .\" Modified 1998 by Andi Kleen .\" Modified 11 May 2001 by Sam Varshavchik .\" Translated into Spanish Tue Feb 17 15:26:14 CET 1998 by Gerardo .\" Aburruzaga García .\" Translation revised Mon Aug 17 1998 by Juan Piernas .\" Translation revised Wed Apr 14 1999 by Juan Piernas .\" Modified 1998 by Andi Kleen .\" Translation revised Sat Jun 26 1999 by Juan Piernas .\" Revisado por Miguel Pérez Ibars el 18-noviembre-2004 .\" .TH LISTEN 2 "22 octubre 1996" "BSD" "Manual del Programador de Linux" .SH NOMBRE listen \- espera conexiones en un conector (socket) .SH SINOPSIS .B #include .sp .BI "int listen(int " s ", int " backlog ); .SH DESCRIPCIÓN Para aceptar conexiones, primero se crea un conector con .BR socket (2), luego se especifica con .B listen el deseo de aceptar conexiones entrantes y un límite de la cola para dichas conexiones, y por último las conexiones son aceptadas mediante .BR accept (2). La llamada .B listen se aplica solamente a conectores de tipo .B SOCK_STREAM o .BR SOCK_SEQPACKET. .PP El parámetro .I backlog define la longitud máxima a la que puede llegar la cola de conexiones pendientes. Si una petición de conexión llega estando la cola llena, el cliente puede recibir un error con una indicación de .B ECONNREFUSED o, si el protocolo subyacente acepta retransmisiones, la petición puede no ser tenida en cuenta, de forma que un reintento tenga éxito. .SH OBSERVACIONES El comportamiento del parámetro .I backlog sobre conectores TCP ha cambiado con la versión 2.2 de Linux. Ahora indica la longitud de la cola para conectores establecidos .I completamente que esperan ser aceptados, en lugar del número de peticiones de conexión incompletas. La longitud máxima de la cola para conectores incompletos se puede configurar con la sysctl .BR tcp_max_syn_backlog . Cuando los "syncookies" están activos, no existe una longitud máxima lógica y la configuración de esta sysctl se ignora. Vea .BR tcp (7) para más información. .SH "VALOR DEVUELTO" En caso de éxito, se devuelve cero. En caso de error, se devuelve \-1 y se pone en .I errno un valor apropiado. .SH ERRORES .TP .B EADDRINUSE Otro conector ya se encuentra escuchando en el mismo puerto. .TP .B EBADF El argumento .I s no es un descriptor válido. .TP .B ENOTSOCK El argumento .I s no es un conector. .TP .B EOPNOTSUPP El conector no es de un tipo que admita la operación .BR listen . .SH "CONFORME A" Single Unix, 4.4BSD, borrador POSIX 1003.1g. La llamada a función .B listen apareció por 1ª vez en 4.2BSD. .SH FALLOS Si el conector es de tipo .B AF_INET y el argumento .I backlog es mayor que la constante .B SOMAXCONN (128 en 2.0 y 2.2), se trunca silenciosamente a .BR SOMAXCONN . Para aplicaciones transportables, no confíe en este valor puesto que BSD (y algunos sistemas derivados de BSD) limitan .I backlog a 5. .SH "VÉASE TAMBIÉN" .BR accept (2), .BR connect (2), .BR socket (2)