1 LISTEN(3C)               Standard C Library Functions               LISTEN(3C)
   2 
   3 NAME
   4      listen - listen for connections on a socket
   5 
   6 LIBRARY
   7      Standard C Library (libc, -lc)
   8 
   9 SYNOPSIS
  10      #include <sys/types.h>
  11      #include <sys/socket.h>
  12 
  13      int
  14      listen(int s, int backlog);
  15 
  16 DESCRIPTION
  17      To accept connections, a socket is first created with socket(3C), a
  18      backlog for incoming connections is specified with listen() and then the
  19      connections are accepted with accept(3C).  The listen() call applies only
  20      to sockets of type SOCK_STREAM or SOCK_SEQPACKET.
  21 
  22      The backlog parameter defines the maximum length the queue of pending
  23      connections may grow to.
  24 
  25      If a connection request arrives with the queue full, the client will
  26      receive an error with an indication of ECONNREFUSED for AF_UNIX sockets.
  27      If the underlying protocol supports retransmission, the connection
  28      request may be ignored so that retries may succeed.  For AF_INET and
  29      AF_INET6 sockets, the TCP will retry the connection.  If the backlog is
  30      not cleared by the time the tcp times out, the connect will fail with
  31      ETIMEDOUT.
  32 
  33 RETURN VALUES
  34      A 0 return value indicates success; -1 indicates an error.
  35 
  36 ERRORS
  37      The call fails if:
  38 
  39      [EBADF]            The argument s is not a valid file descriptor.
  40 
  41      [ENOTSOCK]         The argument s is not a socket.
  42 
  43      [EOPNOTSUPP]       The socket is not of a type that supports the
  44                         operation listen().
  45 
  46 MT-LEVEL
  47      Safe
  48 
  49 SEE ALSO
  50      accept(3C), connect(3C), socket(3C), socket.h(3HEAD), attributes(5)
  51 
  52 NOTES
  53      There is currently no backlog limit.
  54 
  55 illumos                         August 2, 2018                         illumos