IPB
>  Man Pages > Unix > FreeBSD 6.2 > Section 2 > listen man page

listen man page

Section 2 - FreeBSD 6.2 Man Pages

Other operating system man pages available here


Advanced Search

Hopefully, this page is exactly what you are looking for, but if not, you can always find further assistance on Unix/Linux Forum!


LISTEN(2)                 FreeBSD System Calls Manual                LISTEN(2)


NAME

     listen -- listen for connections on a socket


LIBRARY

     Standard C Library (libc, -lc)


SYNOPSIS

     #include <sys/types.h>
     #include <sys/socket.h>

     int
     listen(int s, int backlog);


DESCRIPTION

     To accept connections, a socket is first created with socket(2), a will-
     ingness to accept incoming connections and a queue limit for incoming
     connections are specified with listen(), and then the connections are
     accepted with accept(2).  The listen() system call applies only to sock-
     ets of type SOCK_STREAM or SOCK_SEQPACKET.

     The backlog argument defines the maximum length the queue of pending con-
     nections may grow to.  The real maximum queue length will be 1.5 times
     more than the value specified in the backlog argument.  A subsequent
     listen() system call on the listening socket allows the caller to change
     the maximum queue length using a new backlog argument.  If a connection
     request arrives with the queue full the client may receive an error with
     an indication of ECONNREFUSED, or, in the case of TCP, the connection
     will be silently dropped.

     Current queue lengths of listening sockets can be queried using
     netstat(1) command.

     Note that before FreeBSD 4.5 and the introduction of the syncache, the
     backlog argument also determined the length of the incomplete connection
     queue, which held TCP sockets in the process of completing TCP's 3-way
     handshake.  These incomplete connections are now held entirely in the
     syncache, which is unaffected by queue lengths.  Inflated backlog values
     to help handle denial of service attacks are no longer necessary.

     The sysctl(3) MIB variable ``kern.ipc.somaxconn'' specifies a hard limit
     on backlog; if a value greater than kern.ipc.somaxconn or less than zero
     is specified, backlog is silently forced to kern.ipc.somaxconn.


INTERACTION WITH ACCEPT FILTERS

     When accept filtering is used on a socket, a second queue will be used to
     hold sockets that have connected, but have not yet met their accept fil-
     tering criteria.  Once the criteria has been met, these sockets will be
     moved over into the completed connection queue to be accept(2)ed.  If
     this secondary queue is full and a new connection comes in, the oldest
     socket which has not yet met its accept filter criteria will be termi-
     nated.

     This secondary queue, like the primary listen queue, is sized according
     to the backlog argument.


RETURN VALUES

     The listen() function returns the value 0 if successful; otherwise the
     value -1 is returned and the global variable errno is set to indicate the
     error.


ERRORS

     The listen() system call will fail if:

     [EBADF]            The argument s is not a valid descriptor.

     [EINVAL]           The socket is already connected, or in the process of
                        being connected.

     [ENOTSOCK]         The argument s is not a socket.

     [EOPNOTSUPP]       The socket is not of a type that supports the opera-
                        tion listen().


SEE ALSO

     netstat(1), accept(2), connect(2), socket(2), sysctl(3), sysctl(8),
     accept_filter(9)


HISTORY

     The listen() system call appeared in 4.2BSD.  The ability to configure
     the maximum backlog at run-time, and to use a negative backlog to request
     the maximum allowable value, was introduced in FreeBSD 2.2.

FreeBSD 6.2                     August 29, 2005                    FreeBSD 6.2


Man(1) output converted with man2html and wrapped by fishsponge

This page was generated on Wed Sep 19 20:03:45 BST 2007

Your favourite pages:

No pages logged yet.
Trying to save cookie...

Top 10 most popular pages:

sqlite3 man page (4767 hits)
(openSUSE 10.2)

adv_cap_autoneg man page (4617 hits)
(Solaris 10 11_06)

CPAN man page (4352 hits)
(Suse Linux 10.1)

ssh man page (4196 hits)
(Suse Linux 10.1)

svn man page (3410 hits)
(FreeBSD 6.2)

startproc man page (1957 hits)
(Suse Linux 10.1)

pprosetup man page (1746 hits)
(Solaris 10 11_06)

netcat man page (1697 hits)
(Suse Linux 10.1)

signal man page (1686 hits)
(Suse Linux 10.1)

ssh-socks5-proxy-connect man page (1661 hits)
(Solaris 10 11_06)

Useful Links

Go Back

Visitor Statistics


Valid XHTML 1.0 Transitional     Valid CSS!

Partners: Cambridge Plus :: Pyrenees Summer Activities :: SolidWorks 3D CAD :: <Link Available>
Unix Man Pages / Linux Man Pages :: HiFi Forum :: SIP VoIP Phone & Provider Reviews :: UNIX/Linux Forum Archives

More info on advertising on Unix/Linux Forum