pr_acceptread.rst (2284B)
1 PR_AcceptRead 2 ============= 3 4 Accepts a new connection and receives a block of data. 5 6 7 Syntax 8 ------ 9 10 .. code:: 11 12 #include <prio.h> 13 14 PRInt32 PR_AcceptRead( 15 PRFileDesc *listenSock, 16 PRFileDesc **acceptedSock, 17 PRNetAddr **peerAddr, 18 void *buf, 19 PRInt32 amount, 20 PRIntervalTime timeout); 21 22 23 Parameters 24 ~~~~~~~~~~ 25 26 The function has the following parameters: 27 28 ``listenSock`` 29 A pointer to a :ref:`PRFileDesc` object representing a socket descriptor 30 that has been called with the :ref:`PR_Listen` function, also known as 31 the rendezvous socket. 32 ``acceptedSock`` 33 A pointer to a pointer to a :ref:`PRFileDesc` object. On return, 34 ``*acceptedSock`` points to the :ref:`PRFileDesc` object for the newly 35 connected socket. This parameter is valid only if the function return 36 does not indicate failure. 37 ``peerAddr`` 38 A pointer a pointer to a :ref:`PRNetAddr` object. On return, 39 ``peerAddr`` points to the address of the remote socket. The 40 :ref:`PRNetAddr` object that ``peerAddr`` points to will be in the 41 buffer pointed to by ``buf``. This parameter is valid only if the 42 function return does not indicate failure. 43 ``buf`` 44 A pointer to a buffer to hold data sent by the peer and the peer's 45 address. This buffer must be large enough to receive ``amount`` bytes 46 of data and two :ref:`PRNetAddr` structures (thus allowing the runtime 47 to align the addresses as needed). 48 ``amount`` 49 The number of bytes of data to receive. Does not include the size of 50 the :ref:`PRNetAddr` structures. If 0, no data will be read from the 51 peer. 52 ``timeout`` 53 The timeout interval only applies to the read portion of the 54 operation. :ref:`PR_AcceptRead` blocks indefinitely until the connection 55 is accepted; the read will time out after the timeout interval 56 elapses. 57 58 59 Returns 60 ~~~~~~~ 61 62 - A positive number indicates the number of bytes read from the peer. 63 - The value -1 indicates a failure. The reason for the failure can be 64 obtained by calling :ref:`PR_GetError`. 65 66 67 Description 68 ----------- 69 70 :ref:`PR_AcceptRead` accepts a new connection and retrieves the newly 71 created socket's descriptor and the connecting peer's address. Also, as 72 its name suggests, :ref:`PR_AcceptRead` receives the first block of data 73 sent by the peer.