161183Sbostic.\" Copyright (c) 1983, 1991, 1993 261183Sbostic.\" The Regents of the University of California. All rights reserved. 320241Smckusick.\" 443568Strent.\" %sccs.include.redist.man% 520241Smckusick.\" 6*65100Smckusick.\" @(#)listen.2 8.2 (Berkeley) 12/11/93 736759Sbostic.\" 847208Scael.Dd 947208Scael.Dt LISTEN 2 1047208Scael.Os BSD 4.2 1147208Scael.Sh NAME 1247208Scael.Nm listen 1347208Scael.Nd listen for connections on a socket 1447208Scael.Sh SYNOPSIS 1547208Scael.Fd #include <sys/socket.h> 1647208Scael.Ft int 1747208Scael.Fn listen "int s" "int backlog" 1847208Scael.Sh DESCRIPTION 1920241SmckusickTo accept connections, a socket 2020241Smckusickis first created with 2147208Scael.Xr socket 2 , 2228107Skarelsa willingness to accept incoming connections and 2328107Skarelsa queue limit for incoming connections are specified with 2447208Scael.Fn listen , 2520241Smckusickand then the connections are 2620241Smckusickaccepted with 2747208Scael.Xr accept 2 . 2820241SmckusickThe 2947208Scael.Fn listen 3020241Smckusickcall applies only to sockets of type 3147208Scael.Dv SOCK_STREAM 3220241Smckusickor 3347208Scael.Dv SOCK_SEQPACKET. 3447208Scael.Pp 3520241SmckusickThe 3647208Scael.Fa backlog 3720241Smckusickparameter defines the maximum length the queue of 3820241Smckusickpending connections may grow to. 3920241SmckusickIf a connection 4028107Skarelsrequest arrives with the queue full the client may 4147208Scaelreceive an error with an indication of 4247208Scael.Er ECONNREFUSED , 4328107Skarelsor, if the underlying protocol supports retransmission, 4428107Skarelsthe request may be ignored so that retries may succeed. 4547208Scael.Sh RETURN VALUES 4647208ScaelA 0 return value indicates success; -1 indicates an error. 4747208Scael.Sh ERRORS 48*65100Smckusick.Fn Listen 49*65100Smckusickwill fail if: 5047208Scael.Bl -tag -width [EOPNOTSUPP] 5147208Scael.It Bq Er EBADF 5247208ScaelThe argument 5347208Scael.Fa s 5447208Scaelis not a valid descriptor. 5547208Scael.It Bq Er ENOTSOCK 5647208ScaelThe argument 5747208Scael.Fa s 5847208Scaelis not a socket. 5947208Scael.It Bq Er EOPNOTSUPP 6047208ScaelThe socket is not of a type that supports the operation 6147208Scael.Fn listen . 6247208Scael.El 6347208Scael.Sh SEE ALSO 6447208Scael.Xr accept 2 , 6547208Scael.Xr connect 2 , 6647208Scael.Xr socket 2 6747208Scael.Sh BUGS 6820241SmckusickThe 6947208Scael.Fa backlog 7020241Smckusickis currently limited (silently) to 5. 7147208Scael.Sh HISTORY 7247208ScaelThe 7347208Scael.Nm 7447208Scaelfunction call appeared in 7547208Scael.Bx 4.2 . 76