ibm-information-center/dist/eclipse/plugins/i5OS.ic.apis_5.4.0.1/gskstartrecv.htm

571 lines
17 KiB
HTML
Raw Normal View History

2024-04-02 14:02:31 +00:00
<!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>gsk_secure_soc_startRecv()--Start asynchronous receive operation on a
secure session</title>
<!-- Begin Header Records -->
<!-- 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. -->
<!-- Change History: -->
<!-- Created for V5R1 -->
<link rel="stylesheet" type="text/css" href="../rzahg/ic.css">
</head>
<body>
<!-- End Header Records -->
<!--Java sync-link-->
<script type="text/javascript" language="Javascript" src="../rzahg/synch.js">
</script>
<a name="Top_Of_Page"></a>
<h2>gsk_secure_soc_startRecv()--Start asynchronous receive operation on a
secure session</h2>
<div class="box" style="width: 80%;">
<br>
&nbsp;&nbsp;Syntax
<pre>
#include &lt;gskssl.h&gt;
#include &lt;qsoasync.h&gt;
int gsk_secure_soc_startRecv (gsk_handle my_session_handle,
int IOCompletionPort,
Qso_OverlappedIO_t * communicationsArea)
</pre>
&nbsp;&nbsp;Service Program Name: QSYS/QSOSSLSR <br>
<!-- iddvc RMBR -->
<br>
&nbsp;&nbsp;Default Public Authority: *USE <br>
<!-- iddvc RMBR -->
<br>
&nbsp;&nbsp;Threadsafe: Yes<br>
<!-- iddvc RMBR -->
<br>
</div>
<p>The <strong>gsk_secure_soc_startRecv()</strong> function is used to initiate
an asynchronous receive operation on a secure session. The supplied receive
buffer cannot be reused by the calling application until the receive is
complete or the I/O completion port specified on the
<strong>gsk_secure_soc_startRecv()</strong> has been destroyed. This API
supports sockets with an address family of AF_INET or AF_INET6 and type SOCK_STREAM only.</p>
<br>
<h3>Parameters</h3>
<dl>
<dt><strong><em>my_session_handle</em></strong>&nbsp;(Input)</dt>
<dd>The handle, returned from <strong>gsk_secure_soc_open()</strong> and used
on the <strong>gsk_secure_soc_init()</strong> API call that initialized the
secure session over which data is to be read.<br>
<br>
</dd>
<dt><strong><em>int IOCompletionPort</em></strong>&nbsp;(Input)</dt>
<dd>The I/O completion port that should be posted when the operation
completes.<br>
<br>
</dd>
<dt><em><strong>Qso_OverlappedIO_t</strong> *
communicationsArea</em>&nbsp;(Input/Output)</dt>
<dd>A pointer to a structure that contains the following information:<br>
<br>
<table cellpadding="5">
<!-- cols="25 75" -->
<tr>
<td align="left" valign="top"><strong><em>descriptorHandle</em></strong> </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"><strong><em>buffer</em></strong> </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"><strong><em>bufferLength</em></strong> </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"><strong><em>postFlag</em></strong> </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.<br>
<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 style="list-style: none">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"><strong><em>postFlagResult</em></strong> </td>
<td align="left" valign="top">(Output) - This field is valid if
gsk_secure_soc_startRecv() 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"><strong><em>fillBuffer</em></strong> </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"><strong><em>returnValue</em></strong> </td>
<td align="left" valign="top">(Output) - IF gsk_secure_soc_startRecv()
completes synchronously (function return value equals GSK_OK), then this field
is set to GSK_OK and field secure data transfer size indicates number of bytes
received. </td>
</tr>
<tr>
<td align="left" valign="top"><em><strong>errnoValue</strong></em> </td>
<td align="left" valign="top">(Output) - When the operation has completed
asynchronously and returnValue is GSK_ERROR_IO, this field will contain an
errno further defining the failure. </td>
</tr>
<tr>
<td align="left" valign="top"><strong><em>operationCompleted</em></strong>
</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
GSKSECURESOCSTARTRECV. </td>
</tr>
<tr>
<td align="left" valign="top"><strong><em>secureDataTransferSize</em></strong>
</td>
<td align="left" valign="top">(Output) - Number of bytes received when
<strong>gsk_secure_soc_startRecv()</strong> completes synchronously (return
value equals GSK_OK). </td>
</tr>
<tr>
<td align="left" valign="top"><strong><em>bytesAvailable</em></strong> </td>
<td align="left" valign="top">Not used. </td>
</tr>
<tr>
<td align="left" valign="top"><strong><em>operationWaitTime</em></strong> </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>
If this timer expires, the operation will be posted to the I/O completion port
with <em>errnoValue</em> set to EAGAIN.<br>
<br>
If this field is set to zero, the operation's asynchronous completion will not
be timed.<br>
<br>
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.<br>
<br>
The minimum operationWaitTime is 1 second. The microseconds field (tv_usec) in
the timeval is not used and must be set to zero. </td>
</tr>
<tr>
<td align="left" valign="top"><strong><em>postedDescriptor</em></strong> </td>
<td align="left" valign="top">Not used - Must be set to zero. </td>
</tr>
<tr>
<td align="left" valign="top"><strong><em>reserved1</em></strong> </td>
<td align="left" valign="top">(Output) - Must be set to hexadecimal zeroes.
</td>
</tr>
<tr>
<td align="left" valign="top"><strong><em>reserved2</em></strong> </td>
<td align="left" valign="top">(Input) - Must be set to hexadecimal zeroes.
</td>
</tr>
</table>
</dd>
</dl>
<br>
<h3>Authorities</h3>
<p>No authorization is required.</p>
<br>
<h3>Return Values</h3>
<p><strong>gsk_secure_soc_startRecv()</strong> returns an integer. Possible
values are:</p>
<ul>
<li>GSK_OK - The function has completed synchronously. The Qso_OverlappedIO_t
communications structure has been updated but nothing has nor will be posted to
the I/O completion port for this operation. Inspect field
secureDataTransferSize in the Qso_OverlappedIO_t communications structure to
determine the number of bytes received.<br>
<br>
</li>
<li>GSK_AS400_ASYNCHRONOUS_RECV - 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.<br>
<br>
</li>
<li>If the function fails, possible values are:<br>
<br>
<dl>
<dt>[GSK_INVALID_HANDLE]</dt>
<dd>
<p>The handle specified was not valid.</p>
</dd>
<dt>[GSK_INVALID_STATE]</dt>
<dd>
<p>The handle is not in the correct state for this operation.</p>
</dd>
<dt>[GSK_INVALID_BUFFER SIZE]</dt>
<dd>
<p>The bufferLength field located in the Qso_OverLappedIO_t communications area
is less than 1.</p>
</dd>
<dt>[GSK_ERROR_BAD_MESSAGE]</dt>
<dd>
<p>SSL received a badly formatted message.</p>
</dd>
<dt>[GSK_ERROR_BAD_MAC]</dt>
<dd>
<p>A bad message authentization code was received.</p>
</dd>
<dt>[GSK_ AS400_ERROR_INVALID_POINTER]</dt>
<dd>
<p>The buffer pointer located in Qso_OverLappedIO_t communications area is not
valid.</p>
</dd>
<dt>[GSK_ERROR_SOCKET_CLOSED]</dt>
<dd>
<p>A <strong>close()</strong> was done on the socket descriptor for this secure
session.</p>
</dd>
<dt>[GSK_INTERNAL_ERROR]</dt>
<dd>
<p>An unexpected error occurred during SSL processing.</p>
</dd>
<dt>[GSK_AS400_ERROR_INVALID_ OVERLAPPEDIO_T]</dt>
<dd>
<p>The Qso_OverLappedIO_t specified was not valid.</p>
</dd>
<dt>[GSK_AS400_ERROR_INVALID_ IOCOMPLETIONPORT]</dt>
<dd>
<p>The I/O completion port specified was not valid.</p>
</dd>
<dt>[GSK_AS400_ERROR_BAD_SOCKET_DESCRIPTOR]</dt>
<dd>
<p>The socket descriptor specified within the gsk_handle was not valid.</p>
</dd>
<dt>[GSK_ERROR_IO]</dt>
<dd>
<p>An error occured in SSL processing; check the <strong>errno</strong>
value.</p>
</dd>
</dl>
</li>
</ul>
<br>
<h3>Error Conditions</h3>
<p>When <strong>gsk_secure_soc_startRecv()</strong> API fails with return code
[GSK_ERROR_IO], <em>errno</em> can be set to:</p>
<dl>
<dt><em>[ECONNRESET]</em></dt>
<dd><p>A connection with a remote socket was reset by that socket.</p></dd>
<dt><em>[EINVAL]</em></dt>
<dd><p>The field operationWaitTime.tv_sec was negative or
operationWaitTime.tv_usec was not zero or postedDescriptor was not zero.</p>
</dd>
<dt><em>[EIO]</em></dt>
<dd><p>Input/output error.</p></dd>
<dt><em>[ENOTCONN]</em></dt>
<dd><p>Requested operation requires a connection.</p></dd>
<dt><em>[EUNATCH]</em></dt>
<dd><p>The protocol required to support the specified address family is not
available at this time.</p></dd>
</dl>
<p>If an <em>errno</em> is returned that is not in this list, see <a href=
"unix14.htm">Errno Values for UNIX-Type Functions</a> for a description of the
<em>errno</em>.</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">CPE3418 E</td>
<td width="85%" 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 &amp;1 in library &amp;2 ended.
Reason code &amp;3.</td>
</tr>
<tr>
<td align="left" valign="top">CPFA081 E</td>
<td align="left" valign="top">Unable to set return value or error code.</td>
</tr>
</table>
<br>
<p><strong>Usage Notes</strong></p>
<ol>
<li>A buffer that is given to <strong>gsk_secure_soc_startRecv()</strong> 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 <strong>gsk_secure_soc_startRecv()</strong> to be
filled, and it is later detected during
<strong>gsk_secure_soc_startRecv()</strong> processing that the buffer has been
freed, it may produce an unrecoverable condition on the socket for which the
<strong>gsk_secure_soc_startRecv()</strong> was issued. If this occurs, an
ECONNABORTED error value will be returned.<br>
<br>
</li>
<li>It is not recommended to intermix
<strong>gsk_secure_soc_startRecv()</strong> and blocking I/O (ie, recv() or
gsk_secure_soc_read()) on the same socket. If this condition occurs, then
pending asynchronous recv I/O will be serviced first before the blocking
I/O.<br>
<br>
</li>
<li>The maximum length of data typically returned will not exceed 16 KB. This
is due to the fact that SSL is a record level protocol and the largest record
allowed is 32 KB minus the necessary SSL record headers.<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.<br>
<br>
</li>
<li>It is strongly suggested that you do not mix the
<strong>gsk_secure_soc_read()</strong> nor
<strong>gsk_secure_soc_startRecv()</strong> APIs with any of the sockets read
functions. However, SSL and socket reads and writes can be mixed, but they must
be performed in matched sets. If a client application writes 100 bytes of data
using one or more of the socket send() calls, then the server application must
read exactly 100 bytes of data using one or more of the socket recv() calls.
This is also true for <strong>gsk_secure_soc_read()</strong> and
<strong>gsk_secure_soc_startRecv()</strong> APIs.<br>
<br>
</li>
<li>A FIONREAD ioctl() cannot be used to determine the amount of data available
for reading by using <strong>gsk_secure_soc_startRecv()</strong>.<br><br></li>
<li>SSL will ignore the out of band (OOB) data indicator. OOB will not affect
the SSL application. OOB will only be data to the SSL protocol.<br></li>
<li>For an SSL enabled socket, which must use a connection-oriented transport
service (that is, TCP), a returned value of zero in the secureDataTransferSize
field indicates one of the following:
<ul>
<li>The partner program has issued a <em>close()</em> for the socket.<br>
<br>
</li>
<li>The partner program has issued a secure close for the secure session. For
example, if the partner program was coded using the GSKit APIs, the partner
issued <strong>gsk_secure_soc_close()</strong>.<br>
<br>
</li>
<li>The partner program has issued a <em>shutdown()</em> to disable writing to
the socket.<br>
<br>
</li>
<li>The connection is broken and the error was returned on a previously issued
socket function.<br>
<br>
</li>
<li>A <em>shutdown()</em> to disable reading was previously done on the
socket.</li>
</ul>
</li>
</ol>
<br>
<h3>Related Information</h3>
<ul>
<li><a href="gsk_secure_soc_close.htm">gsk_secure_soc_close()</a>--Close a Secure
Session<br><br></li>
<li><a href="gsk_secure_soc_init.htm">gsk_secure_soc_init()</a>--Negotiate a secure
session<br><br></li>
<li><a href="gsk_secure_soc_misc.htm">gsk_secure_soc_misc()</a>--Perform
miscellaneous functions for a secure session<br><br></li>
<li><a href="gsk_secure_soc_open.htm">gsk_secure_soc_open()</a>--Get a handle for a
secure session<br><br></li>
<li><a href="gskstartinit.htm">gsk_secure_soc_startInit()</a>--Start asynchronous
operation to negotiate a secure session<br>
<br>
</li>
<li><a href="gskstartsend.htm">gsk_secure_soc_startSend()</a>--Start Asynchronous
Send Operation on a Secure Session<br><br></li>
<li><a href="gsk_secure_soc_write.htm">gsk_secure_soc_write()</a>--Send data on a
secure session<br><br></li>
<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="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>