Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ accept(2) — CLIX 3.1r7.6.22

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

accept(2)

bind(2)

connect(2)

listen(2)

select(2)

socket(2)



  accept(2)                           CLIX                           accept(2)



  NAME

    accept - Accepts a connection on a socket

  LIBRARY

    Berkeley Software Distribution Library (libbsd.a)

  SYNOPSIS

    #include <sys/types.h>

    #include <sys/socket.h>

    int accept(
      int s ,
      struct sockaddr *addr ,
      int *addrlen );

  PARAMETERS

    s         Represents a socket descriptor.

    addr      Contains the address of the peer upon return.

    addrlen   Specifies the amount of space pointed to by addr.

  DESCRIPTION

    The s parameter is a socket created with the socket() function, bound to
    an address with the bind() function, and listening for connections after a
    listen() function call.  The accept() function extracts the first
    connection on the queue of pending connections, creates a new socket with
    the same properties of s, and allocates a new file descriptor for the
    socket.  If no pending connections are present on the queue and the socket
    is marked as nonblocking, accept() returns an error as described below.
    The accepted socket may not be used to accept more connections.  The
    original socket s remains open.

    The addr parameter is a result parameter filled in with the address of the
    connecting entity as known to the communications layer.  The exact format
    of addr is determined by the domain in which the communication is
    occurring.  The addrlen parameter is a value-result parameter; it should
    initially contain the amount of space pointed to by addr.  On return, it
    will contain the actual length (in bytes) of the address returned.  This
    call is used with connection-based socket types.  It is currently used
    with SOCK_STREAM.

    It is possible to select a socket using the select() function, for the
    purposes of performing an accept() function call.




  2/94 - Intergraph Corporation                                              1






  accept(2)                           CLIX                           accept(2)



  RETURN VALUES

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

  ERRORS

    The accept() 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.

    [EFAULT]
           The addr parameter is not in a writable part of the user address
           space.

    [EMFILE]
           The per-process descriptor table is full.

    [ENFILE]
           The system file table is full.

    [ENOBUFS]
           The resources to support this connection are not available.

    [ENXIO]
           The maximum number of open devices was exceeded.

    [EINVAL]
           The addrlen parameter is an invalid size or the socket is not
           listening.

    [EISCONN]
           The socket is already connected.

    [EWOULDBLOCK]
           The socket is marked nonblocking and no connections are present to
           be accepted.

    [EINTR]
           A signal was caught during the accept() function.

  RELATED INFORMATION




  2                                              Intergraph Corporation - 2/94






  accept(2)                           CLIX                           accept(2)



    Functions:  bind(2), connect(2), listen(2), select(2), socket(2)





















































  2/94 - Intergraph Corporation                                              3




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