tor-browser

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

pr_transmitfile.rst (1973B)


      1 PR_TransmitFile
      2 ===============
      3 
      4 Sends a complete file across a connected socket.
      5 
      6 
      7 Syntax
      8 ------
      9 
     10 .. code::
     11 
     12   #include <prio.h>
     13 
     14   PRInt32 PR_TransmitFile(
     15     PRFileDesc *networkSocket,
     16     PRFileDesc *sourceFile,
     17     const void *headers,
     18     PRInt32 hlen,
     19     PRTransmitFileFlags flags,
     20     PRIntervalTime timeout);
     21 
     22 
     23 Parameters
     24 ~~~~~~~~~~
     25 
     26 The function has the following parameters:
     27 
     28 ``networkSocket``
     29   A pointer to a :ref:`PRFileDesc` object representing the connected
     30   socket to send data over.
     31 ``sourceFile``
     32   A pointer to a :ref:`PRFileDesc` object representing the file to send.
     33 ``headers``
     34   A pointer to the buffer holding the headers to be sent before sending
     35   data.
     36 ``hlen``
     37   Length of the ``headers`` buffer in bytes.
     38 ``flags``
     39   One of the following flags:
     40 
     41 - :ref:`PR_TRANSMITFILE_KEEP_OPEN` indicates that the socket will be kept
     42   open after the data is sent.
     43 - :ref:`PR_TRANSMITFILE_CLOSE_SOCKET` indicates that the connection should
     44   be closed immediately after successful transfer of the file.
     45 
     46 ``timeout``
     47   Time limit for completion of the transmit operation.
     48 
     49 
     50 Returns
     51 ~~~~~~~
     52 
     53 -  A positive number indicates the number of bytes successfully written,
     54   including both the headers and the file.
     55 -  The value -1 indicates a failure. If an error occurs while sending
     56   the file, the ``PR_TRANSMITFILE_CLOSE_SOCKET`` flag is ignored. The
     57   reason for the failure can be obtained by calling :ref:`PR_GetError`.
     58 
     59 
     60 Description
     61 -----------
     62 
     63 The :ref:`PR_TransmitFile` function sends a complete file (``sourceFile``)
     64 across a connected socket (``networkSocket``). If ``headers`` is
     65 non-``NULL``, :ref:`PR_TransmitFile` sends the headers across the socket
     66 before sending the file.
     67 
     68 The enumeration ``PRTransmitFileFlags``, used in the ``flags``
     69 parameter, is defined as follows:
     70 
     71 .. code::
     72 
     73   typedef enum PRTransmitFileFlags {
     74     PR_TRANSMITFILE_KEEP_OPEN = 0,
     75     PR_TRANSMITFILE_CLOSE_SOCKET = 1
     76   } PRTransmitFileFlags;