318 lines
8.1 KiB
HTML
318 lines
8.1 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>shutdown()--End Receiving and/or Sending of Data on Socket</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 ========================================== -->
|
|
<!-- Unix8 SCRIPT J converted by B2H R4.1 (346) (CMS) by V2KEA304 -->
|
|
<!-- at RCHVMW2 on 17 Feb 1999 at 11:05:09 -->
|
|
<!--End Header Records -->
|
|
<!-- Edited by Kersten Feb 02 -->
|
|
<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>shutdown()--End Receiving and/or Sending of Data on Socket</h2>
|
|
|
|
<div class="box" style="width: 60%;">
|
|
<br>
|
|
BSD 4.3 Syntax<br>
|
|
<pre>
|
|
#include <sys/types.h>
|
|
#include <sys/socket.h>
|
|
|
|
int shutdown(int <em>socket_descriptor</em>,
|
|
int <em>how</em>)
|
|
</pre>
|
|
|
|
<br>
|
|
Service Program Name: QSOSRV1<br>
|
|
<!-- iddvc RMBR -->
|
|
<br>
|
|
Default Public Authority: *USE<br>
|
|
<!-- iddvc RMBR -->
|
|
<br>
|
|
Threadsafe: Yes<br>
|
|
<!-- iddvc RMBR -->
|
|
<br>
|
|
</div>
|
|
|
|
<br>
|
|
|
|
|
|
<div class="box" style="width: 60%;">
|
|
<br>
|
|
<a href="_xopen_source.htm">UNIX 98 Compatible Syntax</a><br>
|
|
<pre>
|
|
#define _XOPEN_SOURCE 520
|
|
#include <sys/socket.h>
|
|
|
|
int shutdown(int <em>socket_descriptor</em>,
|
|
int <em>how</em>)
|
|
</pre>
|
|
|
|
<br>
|
|
Service Program Name: QSOSRV1<br>
|
|
<!-- iddvc RMBR -->
|
|
<br>
|
|
Default Public Authority: *USE<br>
|
|
<!-- iddvc RMBR -->
|
|
<br>
|
|
Threadsafe: Yes<br>
|
|
<!-- iddvc RMBR -->
|
|
<br>
|
|
</div>
|
|
|
|
<br>
|
|
<p>The <em>shutdown()</em> function is used to disable reading, writing, or
|
|
reading and writing on a socket.</p>
|
|
|
|
<p> There are two versions of
|
|
the API, as shown above. The base i5/OS API uses BSD 4.3 structures and
|
|
syntax. The other uses syntax and structures compatible with the UNIX 98
|
|
programming interface specifications. You can select the UNIX 98 compatible
|
|
interface with the <a href="_xopen_source.htm">_XOPEN_SOURCE</a> macro.</p>
|
|
|
|
<br>
|
|
|
|
|
|
<h3>Parameters</h3>
|
|
|
|
<dl>
|
|
<dt><strong>socket_descriptor</strong></dt>
|
|
|
|
<dd>(Input) The descriptor of the socket to be shut down.<br>
|
|
<br>
|
|
</dd>
|
|
|
|
<dt><strong>how</strong></dt>
|
|
|
|
<dd>(Input) The data flow path to be disabled:
|
|
|
|
<table cellpadding="5">
|
|
<!-- cols="15 85" -->
|
|
<tr>
|
|
<td align="left" valign="top"><samp>SHUT_RD or</samp> 0</td>
|
|
<td align="left" valign="top">No more data can be received.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top"><samp>SHUT_WR or</samp> 1</td>
|
|
<td align="left" valign="top">No more data can be sent.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top"><samp>SHUT_RDWR or</samp> 2</td>
|
|
<td align="left" valign="top">No more data can be sent or received.</td>
|
|
</tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
|
|
<br>
|
|
<h3>Authorities</h3>
|
|
|
|
<p>No authorization is required.</p>
|
|
|
|
<br>
|
|
<h3>Return Value</h3>
|
|
|
|
<p><em>shutdown()</em> returns an integer. Possible values are:</p>
|
|
|
|
<ul>
|
|
<li>-1 (unsuccessful)<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li>0 (successful)</li>
|
|
</ul>
|
|
|
|
<br>
|
|
<h3>Error Conditions</h3>
|
|
|
|
<p>When <em>shutdown()</em> fails, <em>errno</em> can be set to one of the
|
|
following:</p>
|
|
|
|
<table cellpadding="5">
|
|
<!-- cols="15 85" -->
|
|
<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>[EINVAL]</em></td>
|
|
<td align="left" valign="top">Parameter not valid.
|
|
|
|
<p>This error code indicates one of the following:</p>
|
|
|
|
<ul>
|
|
<li>The socket pointed to by the <em>socket_descriptor</em> parameter is using
|
|
a connection-oriented transport service. Also, the transport service is in a
|
|
state in which sends and receives are disallowed (for example, connection has
|
|
been reset by peer).<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li>The <em>how</em> parameter specifies a value that is not valid.</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top"><img src="delta.gif" alt="Start of change">
|
|
<em>[ENOTCONN]</em></td>
|
|
<td align="left" valign="top">The specified descriptor does not reference a
|
|
connected socket. <img src="deltaend.gif" alt="End of change"><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>[EIO]</em></td>
|
|
<td align="left" valign="top">Input/output error.<br>
|
|
<br>
|
|
</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.
|
|
|
|
<p><strong>Note:</strong> This <em>errno</em> is not returned if the
|
|
<em>how</em> parameter is 0.</p>
|
|
</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 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>
|
|
|
|
<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>
|
|
<br>
|
|
<h3>Usage Notes</h3>
|
|
|
|
<ol>
|
|
<li>Issuing a <em>shutdown()</em> with a <em>how</em> parameter of 0 causes any
|
|
new data received for the socket to be discarded. Any input functions for this
|
|
socket complete with a 0, meaning that end-of-file has been reached.
|
|
<img src="delta.gif" alt="Start of change"> If the socket is being shared
|
|
across multiple processes, any blocking input operations are deblocked by this
|
|
action.<img src="deltaend.gif" alt="End of change"><br>
|
|
<br>
|
|
</li>
|
|
|
|
<li>Issuing a <em>shutdown()</em> with a <em>how</em> parameter of 1 results in
|
|
all output functions being failed with an error of <samp>[epipe]</samp>. The
|
|
process issuing the output operation will receive a synchronous
|
|
<samp>sigpipe</samp> signal. This also sends a normal close sequence to the partner
|
|
program. Receive operations issued by the partner program receive a return
|
|
value of 0 once all previous data has been received.
|
|
<img src="delta.gif" alt="Start of change"> If the socket is being shared
|
|
across multiple processes or threads, any blocking output functions are deblocked
|
|
with a return value of -1 and an error code of <samp>[epipe]</samp>.
|
|
<img src="deltaend.gif" alt="End of change"><br>
|
|
<br>
|
|
</li>
|
|
|
|
<li>Issuing a <em>shutdown()</em> with a <em>how</em> parameter of 2 results in
|
|
the actions listed for a <em>how</em> parameter of 0 being performed first,
|
|
followed by the actions listed for a <em>how</em> parameter of 1.<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li>Issuing a <em>shutdown()</em> on socket connected through a <em>SOCKS
|
|
server</em> is not supported.<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li>When you develop in C-based
|
|
languages and an application is compiled with the _XOPEN_SOURCE macro defined
|
|
to the value 520 or greater, the <em>shutdown()</em> API is mapped to
|
|
<em>qso_shutdown98()</em>.</li>
|
|
</ol>
|
|
|
|
<br>
|
|
|
|
|
|
<h3>Related Information</h3>
|
|
|
|
<ul>
|
|
<li><a href=
|
|
"_xopen_source.htm">_XOPEN_SOURCE</a>--Using _XOPEN_SOURCE for the UNIX 98
|
|
compatible interface<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li><a href="close.htm">close()</a>--Close File or Socket Descriptor</li>
|
|
</ul>
|
|
|
|
<br>
|
|
<hr>
|
|
API introduced: V3R1
|
|
|
|
<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>
|
|
|