mozilla

Revision 62866 of PR_Recv

  • Revision slug: PR_Recv
  • Revision title: PR_Recv
  • Revision id: 62866
  • Created:
  • Creator: Rappo
  • Is current revision? No
  • Comment

Revision Content

{{ Nsprapiref("I/O Functions") }}

Receives bytes from a connected socket.

Syntax

#include <prio.h> 

PRInt32 PR_Recv(
  PRFileDesc *fd, 
  void *buf, 
  PRInt32 amount, 
  PRIntn flags, 
  PRIntervalTime timeout);

Parameters

The function has the following parameters:

fd
A pointer to a PRFileDesc object representing a socket.
buf
A pointer to a buffer to hold the data received.
amount
The size of buf (in bytes).
flags
This obsolete parameter must always be zero.
timeout
A value of type PRIntervalTime specifying the time limit for completion of the receive operation.

Returns

The function returns one of the following values:

  • A positive number indicates the number of bytes actually received.
  • The value 0 means the network connection is closed.
  • The value -1 indicates a failure. The reason for the failure can be obtained by calling PR_GetError.

Description

PR_Recv blocks until some positive number of bytes are transferred, a timeout occurs, or an error occurs. No more than amount bytes will be transferred.

Revision Source

<p>
{{ Nsprapiref("I/O Functions") }}
</p><p>Receives bytes from a connected socket.
</p>
<h3 name="Syntax"> Syntax </h3>
<pre class="eval">#include &lt;prio.h&gt; 

<a href="en/PRInt32">PRInt32</a> PR_Recv(
  <a href="en/PRFileDesc">PRFileDesc</a> *fd, 
  void *buf, 
  <a href="en/PRInt32">PRInt32</a> amount, 
  <a href="en/PRIntn">PRIntn</a> flags, 
  <a href="en/PRIntervalTime">PRIntervalTime</a> timeout);
</pre>
<h3 name="Parameters"> Parameters </h3>
<p>The function has the following parameters:
</p>
<dl><dt><code>fd</code>
</dt><dd>A pointer to a <a href="en/PRFileDesc">PRFileDesc</a> object representing a socket.
</dd><dt><code>buf</code>
</dt><dd>A pointer to a buffer to hold the data received.
</dd><dt><code>amount</code>
</dt><dd>The size of <code>buf</code> (in bytes).
</dd><dt><code>flags</code>
</dt><dd>This obsolete parameter must always be zero.
</dd><dt><code>timeout</code>
</dt><dd>A value of type <code><a href="en/PRIntervalTime">PRIntervalTime</a></code> specifying the time limit for completion of the receive operation.
</dd></dl>
<h3 name="Returns"> Returns </h3>
<p>The function returns one of the following values:
</p>
<ul><li> A positive number indicates the number of bytes actually received.
</li><li> The value 0 means the network connection is closed.
</li><li> The value -1 indicates a failure. The reason for the failure can be obtained by calling <code><a href="en/PR_GetError">PR_GetError</a></code>.
</li></ul>
<h3 name="Description"> Description </h3>
<p><code>PR_Recv</code> blocks until some positive number of bytes are transferred, a timeout occurs, or an error occurs. No more than <code>amount</code> bytes will be transferred.
</p>
Revert to this revision