


accept(3)                                               accept(3)


NNAAMMEE
       accept - accept a connection on a socket

SSYYNNOOPPSSIISS
       ##iinncclluuddee <<ssyyss//ssoocckkeett..hh>>

   AAFF__UUNNIIXX oonnllyy::
       ##iinncclluuddee <<ssyyss//uunn..hh>>

       iinntt aacccceepptt((iinntt ss,, ssttrruucctt ssoocckkaaddddrr **aaddddrr,, ssiizzee__tt **aaddddrrlleenn));;

DDEESSCCRRIIPPTTIIOONN
       This call is used with connection-based socket types, such
       as  SOCK_STREAM.   The  argument  _s is a socket descriptor
       created with _s_o_c_k_e_t(3), bound to an address with  _b_i_n_d(3),
       and  listening  for connections after a _l_i_s_t_e_n(3).  _a_c_c_e_p_t
       extracts the first connection on the queue of pending con-
       nections, creates a new socket with the same properties as
       _s, and allocates  a  new  file  descriptor,  _n_s,  for  the
       socket.   If  no  pending  connections  are present on the
       queue and non-blocking mode has not been enabled using the
       O_NDELAY _f_c_n_t_l flag, _a_c_c_e_p_t blocks the caller until a con-
       nection is present.  O_NDELAY is defined in <ffccnnttll..hh>.  If
       the  socket  is marked non-blocking and no pending connec-
       tions are present on the queue, _a_c_c_e_p_t returns an error as
       described  below.  The accepted socket, _n_s, cannot be used
       to accept more connections.  The original socket _s remains
       open.   It  is possible to determine if a listening socket
       has pending connection requests ready for an  _a_c_c_e_p_t  call
       by using _s_e_l_e_c_t(3) for reading.

       The  argument  _a_d_d_r should point to a local socket address
       structure.  The _a_c_c_e_p_t call fills in this  structure  with
       the  address  of  the  connecting  entity, as known to the
       underlying protocol.  The format of  the  address  depends
       upon  the protocol and the address-family of the socket _s.
       The _a_d_d_r_l_e_n is a pointer to an argument of type size_t; it
       should initially contain the size of the structure pointed
       to by _a_d_d_r.  On return, it contains the actual length  (in
       bytes)  of the address returned.  If the memory pointed to
       by _a_d_d_r is not large enough to contain the entire address,
       only  the first _a_d_d_r_l_e_n bytes of the address are returned.

RREETTUURRNN VVAALLUUEE
       The call returns -1 on error.  If successful, it returns a
       non-negative   integer  which  is  a  descriptor  for  the
       accepted socket.

DDIIAAGGNNOOSSTTIICCSS
       _a_c_c_e_p_t fails if:

       [EBADF]                  The file descriptor _s is invalid.

       [EOPNOTSUPP]             The socket referenced by _s is not



                             MiNT-Net                           1





accept(3)                                               accept(3)


                                of type SOCK_STREAM.

       [EWOULDBLOCK]            Non-blocking I/O is enabled using
                                O_NDELAY  and  no connections are
                                present to be accepted.

       [EMFILE]                 The  maximum   number   of   file
                                descriptors  for this process are
                                already currently open.

       [ENOMEM]                 No  buffer  space  is  available.
                                The  _a_c_c_e_p_t cannot complete.  The
                                queued socket connect request  is
                                aborted.

       [ECONNABORTED]           The  socket  referenced  by _s has
                                been _s_h_u_t_d_o_w_n for reading.

       [EINVAL]                 The socket referenced by _s is not
                                currently  a  listening socket or
                                has been fully _s_h_u_t_d_o_w_n.  A  _l_i_s_-
                                _t_e_n must be done before an _a_c_c_e_p_t
                                is allowed.  The file  descriptor
                                _s   references   a  file,  not  a
                                socket.

       [EINTR]                  The call  was  interrupted  by  a
                                signal  before a valid connection
                                arrived.

SSEEEE AALLSSOO
       bind(3), connect(3), listen(3), select(3), socket(3).

























                             MiNT-Net                           2


