MDN’s new design is in Beta! A sneak peek:

Reads bytes from a file or socket.


#include <prio.h> 

PRInt32 PR_Read(PRFileDesc *fd, 
               void *buf, 
               PRInt32 amount);


The function has the following parameters:

A pointer to a PRFileDesc object for the file or socket.
A pointer to a buffer to hold the data read in. On output, the buffer contains the data.
The size of buf (in bytes).


One of the following values:

  • A positive number indicates the number of bytes actually read in.
  • The value 0 means end of file is reached or the network connection is closed.
  • The value -1 indicates a failure. To get the reason for the failure, call PR_GetError.


The thread invoking PR_Read blocks until it encounters an end-of-stream indication, some positive number of bytes (but no more than amount bytes) are read in, or an error occurs.

Document Tags and Contributors

 Contributors to this page: teoli, Callek, alecananian
 Last updated by: teoli,