pr_write.rst (1076B)
1 PR_Write 2 ======== 3 4 Writes a buffer of data to a file or socket. 5 6 7 Syntax 8 ------ 9 10 .. code:: 11 12 #include <prio.h> 13 14 PRInt32 PR_Write( 15 PRFileDesc *fd, 16 const void *buf, 17 PRInt32 amount); 18 19 20 Parameters 21 ~~~~~~~~~~ 22 23 The function has the following parameters: 24 25 ``fd`` 26 A pointer to the :ref:`PRFileDesc` object for a file or socket. 27 ``buf`` 28 A pointer to the buffer holding the data to be written. 29 ``amount`` 30 The amount of data, in bytes, to be written from the buffer. 31 32 33 Returns 34 ~~~~~~~ 35 36 One of the following values: 37 38 - A positive number indicates the number of bytes successfully written. 39 - The value -1 indicates that the operation failed. The reason for the 40 failure is obtained by calling :ref:`PR_GetError`. 41 42 43 Description 44 ----------- 45 46 The thread invoking :ref:`PR_Write` blocks until all the data is written or 47 the write operation fails. Therefore, the return value is equal to 48 either ``amount`` (success) or -1 (failure). Note that if :ref:`PR_Write` 49 returns -1, some data (less than ``amount`` bytes) may have been written 50 before an error occurred.