tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

pr_recvfrom.rst (1514B)


      1 PR_RecvFrom
      2 ===========
      3 
      4 Receives bytes from a socket and stores the sending peer's address.
      5 
      6 
      7 Syntax
      8 ------
      9 
     10 .. code::
     11 
     12   #include <prio.h>
     13 
     14   PRInt32 PR_RecvFrom(
     15     PRFileDesc *fd,
     16     void *buf,
     17     PRInt32 amount,
     18     PRIntn flags,
     19     PRNetAddr *addr,
     20     PRIntervalTime timeout);
     21 
     22 
     23 Parameters
     24 ~~~~~~~~~~
     25 
     26 The function has the following parameters:
     27 
     28 ``fd``
     29   A pointer to a :ref:`PRFileDesc` object representing a socket.
     30 ``buf``
     31   A pointer to a buffer containing the data received.
     32 ``amount``
     33   The size of ``buf`` (in bytes).
     34 ``flags``
     35   This obsolete parameter must always be zero.
     36 ``addr``
     37   A pointer to the :ref:`PRNetAddr` object that will be filled in with the
     38   address of the sending peer on return.
     39 ``timeout``
     40   A value of type :ref:`PRIntervalTime` specifying the time limit for
     41   completion of the receive operation.
     42 
     43 
     44 Returns
     45 ~~~~~~~
     46 
     47 The function returns one of the following values:
     48 
     49 -  A positive number indicates the number of bytes actually received.
     50 -  The value 0 means the network connection is closed.
     51 -  The value -1 indicates a failure. The reason for the failure can be
     52   obtained by calling :ref:`PR_GetError`.
     53 
     54 
     55 Description
     56 -----------
     57 
     58 :ref:`PR_RecvFrom` receives up to a specified number of bytes from socket,
     59 which may or may not be connected. The operation blocks until one or
     60 more bytes are transferred, a timeout has occurred, or there is an
     61 error. No more than ``amount`` bytes will be transferred.
     62 :ref:`PR_RecvFrom` is usually used with a UDP socket.