File: pr_writev.rst

package info (click to toggle)
thunderbird 1%3A115.16.0esr-1~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 3,476,252 kB
  • sloc: cpp: 6,972,150; javascript: 5,209,211; ansic: 3,507,222; python: 1,137,609; asm: 432,531; xml: 205,149; java: 175,761; sh: 116,485; makefile: 22,152; perl: 13,971; objc: 12,561; yacc: 4,583; pascal: 2,840; lex: 1,720; ruby: 1,075; exp: 762; sql: 666; awk: 580; php: 436; lisp: 430; sed: 70; csh: 10
file content (79 lines) | stat: -rw-r--r-- 1,950 bytes parent folder | download | duplicates (18)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
PR_Writev
=========

Writes data to a socket from multiple buffers.


Syntax
------

.. code::

   #include <prio.h>

   PRInt32 PR_Writev(
     PRFileDesc *fd,
     PRIOVec *iov,
     PRInt32 size,
     PRIntervalTime timeout);

   #define PR_MAX_IOVECTOR_SIZE 16


Parameters
~~~~~~~~~~

The function has the following parameters:

``fd``
   A pointer to a :ref:`PRFileDesc` object for a socket.
``iov``
   An array of ``PRIOVec`` structures that describe the buffers to write
   from.
``size``
   Number of ``PRIOVec`` structures in the ``iov`` array. The value of
   this parameter must not be greater than ``PR_MAX_IOVECTOR_SIZE``. If
   it is, the function will fail and the error will be set to
   ``PR_BUFFER_OVERFLOW_ERROR``.
``timeout``
   A value of type :ref:`PRIntervalTime` describing the time limit for
   completion of the entire write operation.


Returns
~~~~~~~

One of the following values:

-  A positive number indicates the number of bytes successfully written.
-  The value -1 indicates that the operation failed. The reason for the
   failure can be obtained by calling :ref:`PR_GetError`.


Description
-----------

The thread calling :ref:`PR_Writev` blocks until all the data is written or
the write operation fails. Therefore, the return value is equal to
either the sum of all the buffer lengths (on success) or -1 (on
failure). Note that if :ref:`PR_Writev` returns -1, part of the data may
have been written before an error occurred. If the timeout parameter is
not ``PR_INTERVAL_NO_TIMEOUT`` and all the data cannot be written in the
specified interval, :ref:`PR_Writev` returns -1 with the error code
``PR_IO_TIMEOUT_ERROR``.

This is the type definition for ``PRIOVec``:

.. code::

   typedef struct PRIOVec {
     char *iov_base;
     int iov_len;
   } PRIOVec;

The ``PRIOVec`` structure has the following fields:

``iov_base``
   A pointer to the beginning of the buffer.
``iov_len``
   The size of the buffer.