'\" te .\" Copyright 1989 AT&T .\" Copyright (C) 1999, Sun Microsystems, Inc. All Rights Reserved .TH listen 3SOCKET "8 Nov 1999" "SunOS 5.11" "Sockets Library Functions" .SH NAME listen \- listen for connections on a socket .SH SYNOPSIS .LP .nf \fBcc\fR [ \fIflag\fR ... ] \fIfile\fR ... \fB-lsocket\fR \fB -lnsl \fR [ \fIlibrary\fR ... ] #include #include \fBint\fR \fBlisten\fR(\fBint\fR \fIs\fR, \fBint\fR \fIbacklog\fR); .fi .SH DESCRIPTION .sp .LP To accept connections, a socket is first created with \fBsocket\fR(3SOCKET), a backlog for incoming connections is specified with \fBlisten()\fR and then the connections are accepted with \fBaccept\fR(3SOCKET). The \fBlisten()\fR call applies only to sockets of type \fBSOCK_STREAM\fR or \fBSOCK_SEQPACKET\fR. .sp .LP The \fIbacklog\fR parameter defines the maximum length the queue of pending connections may grow to. .sp .LP If a connection request arrives with the queue full, the client will receive an error with an indication of \fBECONNREFUSED\fR for \fBAF_UNIX\fR sockets. If the underlying protocol supports retransmission, the connection request may be ignored so that retries may succeed. For \fBAF_INET\fR and \fBAF_INET6\fRsockets, the \fBTCP\fR will retry the connection. If the \fIbacklog\fR is not cleared by the time the tcp times out, the connect will fail with \fBETIMEDOUT\fR. .SH RETURN VALUES .sp .LP A \fB0\fR return value indicates success; \fB\(mi1\fR indicates an error. .SH ERRORS .sp .LP The call fails if: .sp .ne 2 .mk .na \fB\fBEBADF\fR\fR .ad .RS 14n .rt The argument \fIs\fR is not a valid file descriptor. .RE .sp .ne 2 .mk .na \fB\fBENOTSOCK\fR\fR .ad .RS 14n .rt The argument \fIs\fR is not a socket. .RE .sp .ne 2 .mk .na \fB\fBEOPNOTSUPP\fR\fR .ad .RS 14n .rt The socket is not of a type that supports the operation \fBlisten()\fR. .RE .SH ATTRIBUTES .sp .LP See \fBattributes\fR(5) for descriptions of the following attributes: .sp .sp .TS tab() box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) . ATTRIBUTE TYPEATTRIBUTE VALUE _ MT-LevelSafe .TE .SH SEE ALSO .sp .LP \fBaccept\fR(3SOCKET), \fBconnect\fR(3SOCKET), \fBsocket\fR(3SOCKET), \fBattributes\fR(5), \fBsocket.h\fR(3HEAD) .SH NOTES .sp .LP There is currently no \fIbacklog\fR limit.