Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ accept(3N) — svr4 — mips UMIPS RISC/os 5.01

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

bind(3N)

connect(3N)

listen(3N)

socket(3N)

netconfig(4)



ACCEPT(3N-SVR4)     RISC/os Reference Manual      ACCEPT(3N-SVR4)



NAME
     accept - accept a connection on a socket

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

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

DESCRIPTION
     The argument s is a socket that has been created with
     socket(3N) and bound to an address with bind(3N), and that
     is listening for connections after a call to listen(3N).
     accept() extracts the first connection on the queue of pend-
     ing connections, creates a new socket with the properties of
     s, and allocates a new file descriptor, ns, for the socket.
     If no pending connections are present on the queue and the
     socket is not marked as non-blocking, accept() blocks the
     caller until a connection is present.  If the socket is
     marked as non-blocking and no pending connections are
     present on the queue, accept() returns an error as described
     below.  accept() uses the netconfig(4) file to determine the
     STREAMS device file name associated with s. This is the dev-
     ice on which the connect indication will be accepted.  The
     accepted socket, ns, is used to read and write data to and
     from the socket that connected to ns; it is not used to
     accept more connections.  The original socket (s) remains
     open for accepting further connections.

     The argument addr is a result parameter that is filled in
     with the address of the connecting entity as it is known to
     the communications layer.  The exact format of the addr
     parameter is determined by the domain in which the communi-
     cation occurs.

     addrlen is a value-result parameter.  Initially, it contains
     the amount of space pointed to by addr; on return it con-
     tains the length in bytes of the address returned.

     accept() is used with connection-based socket types,
     currently with SOCK_STREAM.

     It is possible to select(3N) a socket for the purpose of an
     accept() by selecting it for read.  However, this will only
     indicate when a connect indication is pending; it is still
     necessary to call accept().

RETURN VALUE
     accept() returns -1 on error.  If it succeeds, it returns a



                        Printed 11/19/92                   Page 1





ACCEPT(3N-SVR4)     RISC/os Reference Manual      ACCEPT(3N-SVR4)



     non-negative integer that is a descriptor for the accepted
     socket.

ERRORS
     accept() will fail if:

     EBADF               The descriptor is invalid.

     ENOTSOCK            The descriptor does not reference a
                         socket.

     EOPNOTSUPP          The referenced socket is not of type
                         SOCK_STREAM.

     EWOULDBLOCK         The socket is marked as non-blocking and
                         no connections are present to be
                         accepted.

     EPROTO              A protocol error has occurred; for exam-
                         ple, the STREAMS protocol stack has not
                         been initialized.

     ENODEV              The protocol family and type correspond-
                         ing to s could not be found in the
                         netconfig file.

     ENOMEM              There was insufficient user memory
                         available to complete the operation.

     ENOSR               There were insufficient STREAMS
                         resources available to complete the
                         operation.

SEE ALSO
     bind(3N), connect(3N), listen(3N), socket(3N), netconfig(4).




















 Page 2                 Printed 11/19/92



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