Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

accept(2)

connect(2)

socket(2)



  listen(2)                           CLIX                           listen(2)



  NAME

    listen - Listens for connections on a socket

  LIBRARY

    Berkeley Software Distribution Library (libbsd.a)

  SYNOPSIS

    int listen(
      int s ,
      int backlog );

  PARAMETERS

    s         Represents a socket descriptor

    backlog   The size of the queue for incoming connections.

  DESCRIPTION

    To accept connections, a socket is first created with socket().  A
    willingness to accept incoming connections and a queue limit for incoming
    connections are specified with listen().  Then the connections are
    accepted with accept().  The listen() call applies only to sockets with
    type SOCK_STREAM.

    The backlog parameter defines the maximum length for the queue of pending
    connections.  If a connection request arrives with the queue full, the
    client may receive an error with an indication of ECONNREFUSED.
    Otherwise, if the underlying protocol supports retransmission, the request
    may be ignored so that retries may succeed.

  EXAMPLES

    To listen on socket sd with a backlog of 1:

    if (listen(sd, 1) == -1)
         perror("Listen failed");


  CAUTIONS

    The value of backlog is automatically set by the system to 1.

  RETURN VALUES

    Upon successful completion, a value of 0 is returned.  Otherwise, a value
    of -1 is returned and errno is set to indicate the error.




  2/94 - Intergraph Corporation                                              1






  listen(2)                           CLIX                           listen(2)



  ERRORS

    The listen() function fails if one or more of the following is true:

    [EBADF]
           The descriptor is invalid.

    [ENOTSOCK]
           The descriptor references a file, not a socket.

    [EOPNOTSUPP]
           The referenced socket is not of type SOCK_STREAM.

  RELATED INFORMATION

    Functions:  accept(2), connect(2), socket(2)






































  2                                              Intergraph Corporation - 2/94




Typewritten Software • bear@typewritten.org • Edmonds, WA 98026