Bug 1885489 - Part 9: Add SnapshotIterator::readObject(). r=iain
[gecko.git] / docs / nspr / reference / pr_read.rst
bloba6d7c03efa0b7d223cd5fa3f8725e71220a70ac5
1 PR_Read
2 =======
4 Reads bytes from a file or socket.
7 Syntax
8 ------
10 .. code::
12    #include <prio.h>
14    PRInt32 PR_Read(PRFileDesc *fd,
15                   void *buf,
16                   PRInt32 amount);
19 Parameters
20 ~~~~~~~~~~
22 The function has the following parameters:
24 ``fd``
25    A pointer to a :ref:`PRFileDesc` object for the file or socket.
26 ``buf``
27    A pointer to a buffer to hold the data read in. On output, the buffer
28    contains the data.
29 ``amount``
30    The size of ``buf`` (in bytes).
33 Returns
34 ~~~~~~~
36 One of the following values:
38 -  A positive number indicates the number of bytes actually read in.
39 -  The value 0 means end of file is reached or the network connection is
40    closed.
41 -  The value -1 indicates a failure. To get the reason for the failure,
42    call :ref:`PR_GetError`.
45 Description
46 -----------
48 The thread invoking :ref:`PR_Read` blocks until it encounters an
49 end-of-stream indication, some positive number of bytes (but no more
50 than ``amount`` bytes) are read in, or an error occurs.