PR_Recv

  • Revision slug: PR_Recv
  • Revision title: PR_Recv
  • Revision id: 62868
  • Created:
  • Creator: Biesi
  • Is current revision? Yes
  • Comment format the flag name as code; one or more formatting changes

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
Must be zero or PR_MSG_PEEK.
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 id="Syntax" name="Syntax">Syntax</h3>
<pre class="eval">#include &lt;prio.h&gt; 

<a href="/en/PRInt32" title="en/PRInt32">PRInt32</a> PR_Recv(
  <a href="/en/PRFileDesc" title="en/PRFileDesc">PRFileDesc</a> *fd, 
  void *buf, 
  <a href="/en/PRInt32" title="en/PRInt32">PRInt32</a> amount, 
  <a href="/en/PRIntn" title="en/PRIntn">PRIntn</a> flags, 
  <a href="/en/PRIntervalTime" title="en/PRIntervalTime">PRIntervalTime</a> timeout);
</pre>
<h3 id="Parameters" 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" title="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>Must be zero or <code>PR_MSG_PEEK</code>.</dd> <dt><code>timeout</code></dt> <dd>A value of type <code><a href="/en/PRIntervalTime" title="en/PRIntervalTime">PRIntervalTime</a></code> specifying the time limit for completion of the receive operation.</dd>
</dl>
<h3 id="Returns" 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" title="en/PR_GetError">PR_GetError</a></code>.</li>
</ul>
<h3 id="Description" 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