400 lines
12 KiB
HTML
400 lines
12 KiB
HTML
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||
|
<html>
|
||
|
<head>
|
||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||
|
<meta name="Copyright" content="Copyright (c) 2006 by IBM Corporation">
|
||
|
<title>QsoStartRecv()--Start Asynchronous Receive Operation</title>
|
||
|
<!-- All rights reserved. Licensed Materials Property of IBM -->
|
||
|
<!-- US Government Users Restricted Rights -->
|
||
|
<!-- Use, duplication or disclosure restricted by -->
|
||
|
<!-- GSA ADP Schedule Contract with IBM Corp. -->
|
||
|
<!-- Begin Header Records -->
|
||
|
<!-- Created by Steve Simonson for V5R1 -->
|
||
|
<!-- Edited by Kersten Feb 02 -->
|
||
|
<!-- End Header Records -->
|
||
|
<link rel="stylesheet" type="text/css" href="../rzahg/ic.css">
|
||
|
</head>
|
||
|
<body>
|
||
|
<a name="Top_Of_Page"></a>
|
||
|
<!--Java sync-link-->
|
||
|
<script type="text/javascript" language="Javascript" src="../rzahg/synch.js">
|
||
|
</script>
|
||
|
|
||
|
<h2>QsoStartRecv()--Start Asynchronous Receive Operation</h2>
|
||
|
|
||
|
<div class="box" style="width: 60%;">
|
||
|
<br>
|
||
|
Syntax
|
||
|
|
||
|
<pre>
|
||
|
#include <qsoasync.h>
|
||
|
|
||
|
int QsoStartRecv (int socketDescriptor,int IOCompletionPort,
|
||
|
Qso_OverlappedIO_t * communicationsArea)
|
||
|
|
||
|
</pre>
|
||
|
|
||
|
<br>
|
||
|
Service Program Name: QSOSRV3<br>
|
||
|
<!-- iddvc RMBR -->
|
||
|
<br>
|
||
|
Default Public Authority: *USE<br>
|
||
|
<!-- iddvc RMBR -->
|
||
|
<br>
|
||
|
Threadsafe: Yes<br>
|
||
|
<!-- iddvc RMBR -->
|
||
|
<br>
|
||
|
</div>
|
||
|
|
||
|
<p>The QsoStartRecv function is used to initiate a asynchronous receive
|
||
|
operation. The supplied buffer cannot be reused by the calling application
|
||
|
until the receive is complete or the I/O completion port specified on the
|
||
|
QsoStartRecv has been destroyed. This API only supports sockets with an address
|
||
|
family of AF_INET or
|
||
|
AF_INET6 and type
|
||
|
SOCK_STREAM.</p>
|
||
|
|
||
|
<br>
|
||
|
|
||
|
|
||
|
<h3>Parameters</h3>
|
||
|
|
||
|
<dl>
|
||
|
<dt><strong>int socketDescriptor</strong> (Input)</dt>
|
||
|
|
||
|
<dd>The socket descriptor that should be used to receive data into the
|
||
|
specified buffer.<br>
|
||
|
<br>
|
||
|
</dd>
|
||
|
|
||
|
<dt><strong>int IOCompletionPort</strong> (Input)</dt>
|
||
|
|
||
|
<dd>The I/O completion port that should be posted when the operation
|
||
|
completes.<br>
|
||
|
<br>
|
||
|
</dd>
|
||
|
|
||
|
<dt><strong>Qso_OverlappedIO_t</strong> * communicationsArea
|
||
|
(Input/Output)</dt>
|
||
|
|
||
|
<dd>A pointer to a structure that contains the following information:<br>
|
||
|
<br>
|
||
|
|
||
|
|
||
|
<table cellpadding="5">
|
||
|
<!-- cols="20 80" -->
|
||
|
<tr>
|
||
|
<td align="left" valign="top"><em>descriptorHandle</em></td>
|
||
|
<td align="left" valign="top">(Input) - The descriptor handle is application
|
||
|
specific and is never used by the system. This field is intended to make it
|
||
|
easier for the application to keep track of information regarding a given
|
||
|
socket connection.</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top"><em>buffer</em></td>
|
||
|
<td align="left" valign="top">(Input) - A pointer to a buffer into which data
|
||
|
should be read.</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top"><em>bufferLength</em></td>
|
||
|
<td align="left" valign="top">(Input) - The length of the buffer into which
|
||
|
data should be read. Also represents the amount of data requested.</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top"><em>postFlag</em></td>
|
||
|
<td align="left" valign="top">(Input) - The postFlag indicates if this
|
||
|
operation should be posted to the I/O completion port even if it completes
|
||
|
immediately.
|
||
|
|
||
|
<ul>
|
||
|
<li>A 0 value indicates that if the operation is already complete upon return
|
||
|
to the application, then do not post to the I/O completion port.</li>
|
||
|
|
||
|
<li>A 1 value indicates that even if the operation completes immediately upon
|
||
|
return to the application, the result should still be posted to the I/O
|
||
|
completion port.</li>
|
||
|
</ul>
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top"><em>postFlagResult</em></td>
|
||
|
<td align="left" valign="top">(Output) - This field is valid if QsoStartRecv()
|
||
|
returns with 1 and postFlag was set to 1. In this scenario, postFlagResult set
|
||
|
to 1 denotes the operation completed and been posted to the I/O completion port
|
||
|
specified. A value of 0 denotes the operation could not be completed
|
||
|
immediately, but will be handled asynchronously.</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top"><em>fillBuffer</em></td>
|
||
|
<td align="left" valign="top">(Input) - The fillBuffer flag indicates when this
|
||
|
operation should complete. If the fillBuffer flag is 0, then the operation will
|
||
|
complete as soon as any data is available to be received. If the fillBuffer
|
||
|
flag is non-zero, this operation will not complete until enough data has been
|
||
|
received to fill the buffer, an end-of-file condition occurs on the socket, or
|
||
|
an error occurs on a socket.</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top"><em>returnValue</em></td>
|
||
|
<td align="left" valign="top">(Output) - When QsoStartRecv() completes
|
||
|
synchronously (function return value equals 0), then this field indicates the
|
||
|
number of bytes that were actually received. When the recv operation completes
|
||
|
asynchronously, this field contains indication of success or failure. Zero
|
||
|
returned denotes end-of-file state.</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top"><em>errnoValue</em></td>
|
||
|
<td align="left" valign="top">(Output) - When the operation completes
|
||
|
asynchronously and returnValue is negative, this field contains an errno to
|
||
|
indicate the error with which the operation eventually failed.</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top"><em>operationCompleted</em></td>
|
||
|
<td align="left" valign="top">(Output) - If the operation is posted to the I/O
|
||
|
completion port, this field is updated to indicate that the operation was a
|
||
|
QsoStartRecv().</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top">
|
||
|
<em>secureDataTransferSize</em></td>
|
||
|
<td align="left" valign="top">Not used.</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top"><em>bytesAvailable</em></td>
|
||
|
<td align="left" valign="top">Not used.</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top"><em>operationWaitTime</em></td>
|
||
|
<td align="left" valign="top">(Input) - A timeval structure which specifies the
|
||
|
maximum time allowed for this operation to complete asynchronously.
|
||
|
|
||
|
<pre>
|
||
|
struct timeval {
|
||
|
long tv_sec; /* second */
|
||
|
long tv_usec; /* microseconds */
|
||
|
};
|
||
|
</pre>
|
||
|
|
||
|
<p>If this timer expires, the operation will be posted to the I/O completion
|
||
|
port with <em>errnoValue</em> set to EAGAIN.</p>
|
||
|
|
||
|
<p>If this field is set to zero, the operation's asynchronous completion will
|
||
|
not be timed.</p>
|
||
|
|
||
|
<p>If socketDescriptor is closed before the operation completes or times out,
|
||
|
the operation will be posted to the I/O completion port with
|
||
|
<em>errnoValue</em> set to ECLOSED.</p>
|
||
|
|
||
|
<p>The minimum operationWaitTime is 1 second. The microseconds field (tv_usec)
|
||
|
in the timeval is not used and must be set to zero.</p>
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top"><em>postedDescriptor</em></td>
|
||
|
<td align="left" valign="top">Not used - Must be set to zero.</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top"><em>reserved1</em></td>
|
||
|
<td align="left" valign="top">(Input) - Must be set to hex zeroes.</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top"><em>reserved2</em></td>
|
||
|
<td align="left" valign="top">(Input) - Must be set to hex zeroes.</td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
</dd>
|
||
|
</dl>
|
||
|
|
||
|
<br>
|
||
|
|
||
|
|
||
|
<h3>Authorities</h3>
|
||
|
|
||
|
<p>No authorization is required.</p>
|
||
|
|
||
|
<br>
|
||
|
<h3>Return Values</h3>
|
||
|
|
||
|
<p>QsoStartRecv() returns an integer. Possible values are:</p>
|
||
|
|
||
|
<ul>
|
||
|
<li>-1 - The function was not started because an error occurred. Inspect the
|
||
|
<strong>errno</strong> to determine the cause of the failure.</li>
|
||
|
|
||
|
<li>0 - The function has already completed. The Qso_OverlappedIO_t
|
||
|
communications structure has been updated but nothing has or will be posted to
|
||
|
the I/O completion port for this operation. Inspect the returnValue in the
|
||
|
Qso_OverlappedIO_t communications structure to determine the number of bytes
|
||
|
received.</li>
|
||
|
|
||
|
<li>1 - The function has been started. When the function completes (or times out if operationWaitTime was
|
||
|
specified), the
|
||
|
Qso_OverlappedIO_t communications structure will be updated with the results
|
||
|
and the I/O completion port will be posted.</li>
|
||
|
</ul>
|
||
|
|
||
|
<br>
|
||
|
|
||
|
|
||
|
<h3>Errno Conditions</h3>
|
||
|
|
||
|
<p>When QsoStartRecv() fails, errno can be set to one of the following:</p>
|
||
|
|
||
|
<table cellpadding="5">
|
||
|
<!-- cols="15 85" -->
|
||
|
<tr>
|
||
|
<td align="left" valign="top"><em>[EINVAL]</em></td>
|
||
|
<td align="left" valign="top">A buffer length or I/O completion port or
|
||
|
reserved field specified was not valid or postedDescriptor was not zero or operationWaitTime.tv_sec
|
||
|
was negative or operationWaitTime.tv_usec was not zero.<br>
|
||
|
<br>
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top"><em>[ETRUNC]</em></td>
|
||
|
<td align="left" valign="top">Data was truncated on an input, output, or update
|
||
|
operation. Data has been lost.</td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
|
||
|
<p><strong>Note:</strong> The rest of the errno values from <a href=
|
||
|
"recv.htm">recv()</a> also apply to QsoStartRecv().</p>
|
||
|
|
||
|
<br>
|
||
|
|
||
|
|
||
|
<h3>Error Messages</h3>
|
||
|
|
||
|
<table width="100%" cellpadding="5">
|
||
|
<!-- cols="15 85" -->
|
||
|
<tr>
|
||
|
<th align="left" valign="top">Message ID</th>
|
||
|
<th align="left" valign="top">Error Message Text</th>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td width="15%" valign="top">CPFA081 E</td>
|
||
|
<td width="85%" valign="top">Unable to set return value or error code.</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top">CPE3418 E</td>
|
||
|
<td align="left" valign="top">Possible APAR condition or hardware failure.</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top">CPF9872 E</td>
|
||
|
<td align="left" valign="top">Program or service program &1 in library
|
||
|
&2 ended. Reason code &3.</td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
|
||
|
<br>
|
||
|
<br>
|
||
|
|
||
|
|
||
|
<h3>Usage Notes</h3>
|
||
|
|
||
|
<ol>
|
||
|
<li>If QsoStartRecv() partially fills a buffer and then encounters an EFAULT
|
||
|
condition, the QsoStartRecv() will complete with the ETRUNC error value to
|
||
|
indicate that some data has been lost.<br>
|
||
|
<br>
|
||
|
</li>
|
||
|
|
||
|
<li>A buffer that is given to QsoStartRecv() must not be used by the
|
||
|
application again until either it is returned by QsoWaitForIOCompletion() or is
|
||
|
reclaimed by issuing a close() on the socket descriptor or issuing a
|
||
|
QsoDestroyIOCompletionPort() on the I/O completion port. If a buffer is given
|
||
|
to QsoStartRecv() to be filled, and it is later detected during QsoStartRecv
|
||
|
processing that the buffer has been freed, it may produce an unrecoverable
|
||
|
condition on the socket for which the QsoStartRecv() was issued. If this
|
||
|
occurs, an ECONNABORTED error value will be returned.<br>
|
||
|
<br>
|
||
|
</li>
|
||
|
|
||
|
<li>It is not recommended to intermix QsoStartRecv() and blocking I/O (that is,
|
||
|
recv()) on the same socket. If this condition occurs, then pending asynchronous
|
||
|
send I/O will be serviced first before the blocking I/O.<br>
|
||
|
<br>
|
||
|
</li>
|
||
|
|
||
|
<li>Socket option SO_RCVLOWAT is not supported by this API. Semantics similar
|
||
|
to SO_RCVLOWAT can be obtained using the fillBuffer field in the
|
||
|
Qso_OverLappedIO_t structure.<br>
|
||
|
<br>
|
||
|
</li>
|
||
|
|
||
|
<li> Socket option SO_RCVTIMEO
|
||
|
is not supported by this API. Semantics similar to SO_RCVTIMEO can be obtained
|
||
|
using the operationWaitTime field in the Qso_OverLappedIO_t structure.</li>
|
||
|
</ol>
|
||
|
|
||
|
<br>
|
||
|
|
||
|
|
||
|
<h3>Related Information</h3>
|
||
|
|
||
|
<ul>
|
||
|
<li><a href="createiocompletionport.htm">QsoCreateIOCompletionPort()</a>--Create
|
||
|
I/O Completion Port<br>
|
||
|
<br>
|
||
|
</li>
|
||
|
|
||
|
<li><a href="destroyiocompletionport.htm">QsoDestroyIOCompletionPort()</a>--Create
|
||
|
I/O Completion Port<br>
|
||
|
<br>
|
||
|
</li>
|
||
|
|
||
|
<li><a href="postiocompletion.htm">QsoPostIOCompletionPort()</a>--Post Request on
|
||
|
I/O Completion Port<br>
|
||
|
<br>
|
||
|
</li>
|
||
|
|
||
|
<li><a href="startsend.htm">QsoStartSend</a>--Start Asynchronous Send
|
||
|
Operation<br>
|
||
|
<br>
|
||
|
</li>
|
||
|
|
||
|
<li><a href="waitforiocompletion.htm">QsoWaitForIOCompletion()</a>--Wait for I/O
|
||
|
Completion Operation<br>
|
||
|
<br>
|
||
|
</li>
|
||
|
|
||
|
<li><a href="recv.htm">recv()</a>--Receive Data</li>
|
||
|
</ul>
|
||
|
|
||
|
<br>
|
||
|
|
||
|
|
||
|
<hr>
|
||
|
API introduced: V5R1
|
||
|
|
||
|
<hr>
|
||
|
<center>
|
||
|
<table cellpadding="2" cellspacing="2">
|
||
|
<tr align="center">
|
||
|
<td valign="middle" align="center"><a href="#Top_Of_Page">Top</a> |
|
||
|
<a href="unix.htm">UNIX-Type APIs</a> |
|
||
|
<a href="aplist.htm">APIs by category</a> </td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
</center>
|
||
|
</body>
|
||
|
</html>
|
||
|
|