tor-browser

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

pr_writev.rst (1950B)


      1 PR_Writev
      2 =========
      3 
      4 Writes data to a socket from multiple buffers.
      5 
      6 
      7 Syntax
      8 ------
      9 
     10 .. code::
     11 
     12   #include <prio.h>
     13 
     14   PRInt32 PR_Writev(
     15     PRFileDesc *fd,
     16     PRIOVec *iov,
     17     PRInt32 size,
     18     PRIntervalTime timeout);
     19 
     20   #define PR_MAX_IOVECTOR_SIZE 16
     21 
     22 
     23 Parameters
     24 ~~~~~~~~~~
     25 
     26 The function has the following parameters:
     27 
     28 ``fd``
     29   A pointer to a :ref:`PRFileDesc` object for a socket.
     30 ``iov``
     31   An array of ``PRIOVec`` structures that describe the buffers to write
     32   from.
     33 ``size``
     34   Number of ``PRIOVec`` structures in the ``iov`` array. The value of
     35   this parameter must not be greater than ``PR_MAX_IOVECTOR_SIZE``. If
     36   it is, the function will fail and the error will be set to
     37   ``PR_BUFFER_OVERFLOW_ERROR``.
     38 ``timeout``
     39   A value of type :ref:`PRIntervalTime` describing the time limit for
     40   completion of the entire write operation.
     41 
     42 
     43 Returns
     44 ~~~~~~~
     45 
     46 One of the following values:
     47 
     48 -  A positive number indicates the number of bytes successfully written.
     49 -  The value -1 indicates that the operation failed. The reason for the
     50   failure can be obtained by calling :ref:`PR_GetError`.
     51 
     52 
     53 Description
     54 -----------
     55 
     56 The thread calling :ref:`PR_Writev` blocks until all the data is written or
     57 the write operation fails. Therefore, the return value is equal to
     58 either the sum of all the buffer lengths (on success) or -1 (on
     59 failure). Note that if :ref:`PR_Writev` returns -1, part of the data may
     60 have been written before an error occurred. If the timeout parameter is
     61 not ``PR_INTERVAL_NO_TIMEOUT`` and all the data cannot be written in the
     62 specified interval, :ref:`PR_Writev` returns -1 with the error code
     63 ``PR_IO_TIMEOUT_ERROR``.
     64 
     65 This is the type definition for ``PRIOVec``:
     66 
     67 .. code::
     68 
     69   typedef struct PRIOVec {
     70     char *iov_base;
     71     int iov_len;
     72   } PRIOVec;
     73 
     74 The ``PRIOVec`` structure has the following fields:
     75 
     76 ``iov_base``
     77   A pointer to the beginning of the buffer.
     78 ``iov_len``
     79   The size of the buffer.