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

476 lines
14 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>QsoStartAccept()--Start Asynchronous Accept 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>QsoStartAccept()--Start asynchronous accept operation</h2>
<div class="box" style="width: 60%;">
<br>
&nbsp;&nbsp;Syntax
<pre>
#include &lt;sys/socket.h&gt;
#include &lt;qsoasync.h&gt;
int QsoStartAccept (int socketDescriptor,int IOCompletionPort,
Qso_OverlappedIO_t * communicationsArea)
</pre>
<br>
&nbsp;&nbsp;Service Program Name: QSOSRV3<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>QsoStartAccept()</strong> function is used to wait
asynchronously for connection requests. If connection requests are queued, then
QsoStartAccept() takes the first connection request on the queue and creates a
new socket to service the connection request. If no connection requests are
queued, then an asynchronous QsoStartAccept() request is pended onto the socket
and will be transition to the specified I/O completion port once a connection
arrives. 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>socketDescriptor</strong> (Input)</dt>
<dd>The descriptor of the socket on which to wait.<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">Not used.</td>
</tr>
<tr>
<td align="left" valign="top"><em>bufferLength</em></td>
<td align="left" valign="top">Not used.</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
QsoStartAccept() returns with 1 and postFlag was set to 1. In this scenario,
postFlagResult set to 1 denotes the operation completed and has 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">Not used.</td>
</tr>
<tr>
<td align="left" valign="top"><em>returnValue</em></td>
<td align="left" valign="top">When QsoStartAccept() completes synchronously
(function return value equals 0), then this field identifies the socket
descriptor associated with the accepted connection. When the accept operation
completes asynchronously, this field 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
QSOSTARTACCEPT.</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">(Output) - Number of bytes available to be read
from connection. Only valid if returnValue is &gt;=0.</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">(Output) - 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><strong>QsoStartAccept()</strong> 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 obtain connection descriptor and
bytesAvailable.</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 <strong>QsoStartAccept()</strong> fails, errno can be set to one of the
following:</p>
<table cellpadding="5">
<!-- cols="25 75" -->
<tr>
<td align="left" valign="top"><em>[EFAULT]</em></td>
<td align="left" valign="top">Bad address<br>
<br>
</td>
</tr>
<tr>
<td align="left" valign="top"><em>[EINVAL]</em></td>
<td align="left" valign="top">A 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, or a Listen() has not been issued against the socket
referenced by the SocketDescriptor parameter.<br>
<br>
</td>
</tr>
<tr>
<td align="left" valign="top"><em>[EACCES]</em></td>
<td align="left" valign="top">Permission denied.<br>
<p>A connection indication request was received on the socket referenced by the
<em>socket_descriptor</em> parameter, but the process that issued the
<strong>QsoStartAccept()</strong> did not have the appropriate privileges
required to handle the request. The connection indication request is reset by
the system.</p>
</td>
</tr>
<tr>
<td align="left" valign="top"><em>[EBADF]</em></td>
<td align="left" valign="top">Descriptor not valid.<br>
<br>
</td>
</tr>
<tr>
<td align="left" valign="top"><em>[ECONNABORTED]</em></td>
<td align="left" valign="top">Connection ended abnormally.<br>
<p>An <strong>QsoStartAccept()</strong> was issued on a socket for which
receives have been disallowed (due to a <em>shutdown()</em> call).</p>
</td>
</tr>
<tr>
<td align="left" valign="top"><em>[EIO]</em></td>
<td align="left" valign="top">Input/output.<br>
<br>
</td>
</tr>
<tr>
<td align="left" valign="top"><em>[EMFILE]</em></td>
<td align="left" valign="top">Too many descriptors for this process.<br>
<br>
</td>
</tr>
<tr>
<td align="left" valign="top"><em>[ENFILE]</em></td>
<td align="left" valign="top">Too many descriptors in system.<br>
<br>
</td>
</tr>
<tr>
<td align="left" valign="top"><em>[ENOBUFS]</em></td>
<td align="left" valign="top">There is not enough buffer space for the
requested operation.<br>
<br>
</td>
</tr>
<tr>
<td align="left" valign="top"><em>[ENOTSOCK]</em></td>
<td align="left" valign="top">The specified descriptor does not reference a
socket.<br>
<br>
</td>
</tr>
<tr>
<td align="left" valign="top"><em>[EOPNOTSUPP]</em></td>
<td align="left" valign="top">Operation not supported.<br>
<p>The <em>socket_descriptor</em> parameter references a socket that does not
support the <strong>QsoStartAccept()</strong>. The
<strong>QsoStartAccept()</strong> is only valid on sockets with an address
family of AF_INET or
AF_INET6 and type
SOCK_STREAM.</p>
<p>The <em>socket_descriptor</em> parameter references a socket that has
undergone an Rbind(). The <strong>QsoStartAccept()</strong> operation is not
valid on sockets in this state.</p>
</td>
</tr>
<tr>
<td align="left" valign="top"><em>[EUNATCH]</em></td>
<td align="left" valign="top">The protocol required to support the specified
address family is not available at this time.<br>
<br>
</td>
</tr>
<tr>
<td align="left" valign="top"><em>[EUNKNOWN]</em></td>
<td align="left" valign="top">Unknown system state.</td>
</tr>
</table>
<br>
<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 &amp;1 in library &amp;2 ended.
Reason code &amp;3.</td>
</tr>
</table>
<br>
<br>
<h3>Usage Notes</h3>
<ol>
<li>It is not recommended to intermix QsoStartAccept() and accept(). If this
condition occurs, the order the requests will be serviced is undefined.<br><br></li>
<li>The following are inherited by the descriptor returned by the accept()
call:
<ul>
<li>All socket options with a level of SOL_SOCKET.</li>
<li>The status flags:
<ul>
<li>Blocking flag (set/reset either by the <em>iocltl()</em> call with the
FIONBIO request or by the <em>fcntl()</em> call with the F_SETFL command and
the status flag set to O_NONBLOCK).</li>
<li>Asynchronous flag (set/reset either by the <em>ioctl()</em> call with the
FIOASYNC request or by the <em>fcntl()</em> call with the F_SETFL command and
the status flag set to FASYNC).</li>
</ul>
</li>
<li>The process ID or process group ID that is to receive SIGIO or SIGURG
signals (set/reset by either the <em>ioctl()</em> call with the FIOSETOWN or
the SIOCSPGRP request, or by the <em>fcntl()</em> call with the F_SETOWN
command).</li>
</ul><br><br>
</li>
<li>Closing a socket causes any queued but unaccepted connection requests to be
reset.</li>
</ol>
<br>
<h3>Related Information</h3>
<ul>
<li><a href="accept.htm">accept()</a>--Accept Connection<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="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>