pr_accept.rst (1884B)
1 PR_Accept 2 ========= 3 4 Accepts a connection on a specified socket. 5 6 7 Syntax 8 ------ 9 10 .. code:: 11 12 #include <prio.h> 13 14 PRFileDesc* PR_Accept( 15 PRFileDesc *fd, 16 PRNetAddr *addr, 17 PRIntervalTime timeout); 18 19 20 Parameters 21 ~~~~~~~~~~ 22 23 The function has the following parameters: 24 25 ``fd`` 26 A pointer to a :ref:`PRFileDesc` object representing the rendezvous 27 socket on which the caller is willing to accept new connections. 28 ``addr`` 29 A pointer to a structure of type :ref:`PRNetAddr`. On output, this 30 structure contains the address of the connecting entity. 31 ``timeout`` 32 A value of type :ref:`PRIntervalTime` specifying the time limit for 33 completion of the accept operation. 34 35 36 Returns 37 ~~~~~~~ 38 39 The function returns one of the following values: 40 41 - Upon successful acceptance of a connection, a pointer to a new 42 :ref:`PRFileDesc` structure representing the newly accepted connection. 43 - If unsuccessful, ``NULL``. Further information can be obtained by 44 calling :ref:`PR_GetError`. 45 46 47 Description 48 ----------- 49 50 The socket ``fd`` is a rendezvous socket that has been bound to an 51 address with :ref:`PR_Bind` and is listening for connections after a call 52 to :ref:`PR_Listen`. :ref:`PR_Accept` accepts the first connection from the 53 queue of pending connections and creates a new socket for the newly 54 accepted connection. The rendezvous socket can still be used to accept 55 more connections. 56 57 If the ``addr`` parameter is not ``NULL``, :ref:`PR_Accept` stores the 58 address of the connecting entity in the :ref:`PRNetAddr` object pointed to 59 by ``addr``. 60 61 :ref:`PR_Accept` blocks the calling thread until either a new connection is 62 successfully accepted or an error occurs. If the timeout parameter is 63 not ``PR_INTERVAL_NO_TIMEOUT`` and no pending connection can be accepted 64 before the time limit, :ref:`PR_Accept` returns ``NULL`` with the error 65 code ``PR_IO_TIMEOUT_ERROR``.