383 lines
11 KiB
HTML
383 lines
11 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>QsoStartSend()--Start Asynchronous Send 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 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>QsoStartSend()--Start Asynchronous Send Operation</h2>
|
|
|
|
<div class="box" style="width: 60%;">
|
|
<br>
|
|
Syntax
|
|
|
|
<pre>
|
|
#include <qsoasync.h>
|
|
|
|
int QsoStartSend (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 QsoStartSend function is used to initiate a asynchronous send operation.
|
|
The supplied buffer cannot be reused by the calling application until the send
|
|
is complete or the I/O completion port specified on the QsoStartSend 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 on which the data should be sent.<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 of data that
|
|
should be sent over the socket.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top"><em>bufferLength</em></td>
|
|
<td align="left" valign="top">(Input) - The length of the data to be sent.</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 QsoStartSend()
|
|
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) - Only used on QsoStartRecv(). Ignored on
|
|
QsoStartSend().</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top"><em>returnValue</em></td>
|
|
<td align="left" valign="top">(Output) - When QsoStartSend() completes
|
|
synchronously (function return value equals 0), then this field indicates the
|
|
number of bytes that was actually sent. When the send operation completes
|
|
asynchronously, this filed contains indication of success or failure.</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 will contain 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
|
|
QsoStartSend().</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top" nowrap>
|
|
<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>QsoStartSend() 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
|
|
sent.</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 QsoStartSend() fails, errno can be set to one of the following:</p>
|
|
|
|
<table cellpadding="5">
|
|
<!-- cols="10 90" -->
|
|
<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.</td>
|
|
</tr>
|
|
</table>
|
|
|
|
<p><strong>Note:</strong> The rest of the errno values from <a href=
|
|
"send.htm">send()</a> also apply to QsoStartSend().</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>It is important for application programmers to keep in mind that since
|
|
QsoStartSend() is asynchronous, care should be used to control how many of
|
|
these functions are outstanding. When a TCP socket becomes flow control blocked
|
|
such that the QsoStartSend() is not able to pass the data to the TCP socket
|
|
immediately, the return value will be 1. Applications that send large amounts
|
|
of data should have the postFlag set to 0. This allows the application to use a
|
|
return value of 1 as an indication that the socket has become flow control
|
|
blocked. The application should then wait for the outstanding operation to
|
|
complete before issuing another QsoStartSend(). This will ensure that the
|
|
application does not exhaust system buffer resources.<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li>A buffer that is given to QsoStartSend() 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 QsoStartSend() to be sent, and it is later detected during QsoStartSend()
|
|
processing that the buffer has been freed, it may produce an unrecoverable
|
|
condition on the socket for which the QsoStartSend() was issued. If this
|
|
occurs, an ECONNABORTED error value will be returned.<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li>It is not recommended to intermix QsoStartSend() and blocking I/O (that is,
|
|
send()) on the same socket. If one does, then the pending asynchronous send I/O
|
|
will be serviced before blocking I/O once data can be sent.<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li> Socket option SO_SNDTIMEO
|
|
is not supported by this API. Semantics similar to SO_SNDTIMEO 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>--Destroy
|
|
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="startrecv.htm">QsoStartRecv</a>--Start Asynchronous Recv
|
|
Operation<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li><a href="waitforiocompletion.htm">QsoWaitForIOCompletion()</a>--Wait for I/O
|
|
Completion Operation<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li><a href="send.htm">send()</a>--Send 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>
|
|
|