368 lines
8.5 KiB
HTML
368 lines
8.5 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>socketpair()--Create a Pair of Sockets</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 -->
|
|
<!-- Change History: -->
|
|
<!-- 021021 JTROUS Changes for Virus scanner, 98860, V5R3 -->
|
|
<!-- and add 'lost' socket-vector description -->
|
|
<!-- 040212 JTROUS Fix doc on scanning,match late ENOTSUP, v5r4 -->
|
|
<!-- 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>socketpair()--Create a Pair of Sockets</h2>
|
|
|
|
<div class="box" style="width: 60%;">
|
|
<br>
|
|
BSD 4.3 Syntax<br>
|
|
<pre>
|
|
#include <sys/types.h>
|
|
#include <sys/socket.h>
|
|
|
|
int socketpair(int <em>address_family</em>,
|
|
int <em>type</em>,
|
|
int <em>protocol</em>,
|
|
int *<em>socket_vector</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 socketpair(int <em>address_family</em>,
|
|
int <em>type</em>,
|
|
int <em>protocol</em>,
|
|
int <em>socket_vector</em>[2])
|
|
</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>socketpair()</em> function is used to create a pair of unnamed,
|
|
connected sockets in the <samp>AF_UNIX</samp> or <samp>AF_UNIX_CCSID</samp>
|
|
<em>address_family</em>.</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>address_family</strong></dt>
|
|
|
|
<dd>(Input) The address family to be used with the sockets. Supported values
|
|
are:<br>
|
|
<br>
|
|
<table cellpadding="5">
|
|
<!-- cols="15 85" -->
|
|
<tr>
|
|
<td align="left" valign="top"><samp>AF_UNIX</samp> or
|
|
<samp>AF_UNIX_CCSID</samp></td>
|
|
<td align="left" valign="top">For interprocess communications between processes
|
|
on the same system in the UNIX domain.</td>
|
|
</tr>
|
|
</table>
|
|
|
|
<br>
|
|
</dd>
|
|
|
|
<dt><strong>type</strong></dt>
|
|
|
|
<dd>(Input) The type of communications desired. Supported values are:<br>
|
|
<br>
|
|
</dl>
|
|
|
|
|
|
<table cellpadding="5">
|
|
<!-- cols="15 85" -->
|
|
<tr>
|
|
<td align="left" valign="bottom" width="20%"><samp>SOCK_DGRAM</samp></td>
|
|
<td align="left" valign="bottom" width="80%">Indicates a datagram socket is
|
|
desired.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="bottom"><samp>SOCK_STREAM</samp></td>
|
|
<td align="left" valign="bottom">Indicates a full-duplex stream socket is
|
|
desired.</td>
|
|
</tr>
|
|
</table>
|
|
|
|
|
|
<dl>
|
|
|
|
<dt><strong>protocol</strong></dt>
|
|
|
|
<dd>(Input) The protocol to be used on the sockets. Supported values are:</dd>
|
|
|
|
</dl>
|
|
<table cellpadding="5">
|
|
<!-- cols="5 95" -->
|
|
<tr>
|
|
<td align="left" valign="top">0</td>
|
|
<td align="left" valign="top">Indicates the default protocol for the
|
|
<em>type</em> selected is to be used.</td>
|
|
</tr>
|
|
</table>
|
|
|
|
<Dl>
|
|
<dt><strong>socket_vector</strong></dt>
|
|
<DD>(Output) An integer array of size two that will
|
|
contain the socket descriptors.</dd>
|
|
</DL>
|
|
|
|
|
|
<br>
|
|
|
|
|
|
<h3>Authorities</h3>
|
|
|
|
<p>No authorization is required.</p>
|
|
|
|
<br>
|
|
|
|
|
|
<h3>Return Value</h3>
|
|
|
|
<p><em>socketpair()</em> returns an integer. Possible values are:</p>
|
|
|
|
<ul>
|
|
<li>-1 (unsuccessful)</li>
|
|
|
|
<li>0 (successful)</li>
|
|
</ul>
|
|
|
|
<br>
|
|
|
|
|
|
<h3>Error Conditions</h3>
|
|
|
|
<p>When <em>socketpair()</em> fails, <em>errno</em> can be set to one of the
|
|
following:</p>
|
|
|
|
<table cellpadding="5">
|
|
<!-- cols="25 75" -->
|
|
<tr>
|
|
<td align="left" valign="top"><em>[EAFNOSUPPORT]</em></td>
|
|
<td align="left" valign="top">The type of socket is not supported in this
|
|
protocol family.<br>
|
|
<br>
|
|
</td>
|
|
</tr>
|
|
|
|
<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">Parameter not valid.<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>[EMFILE]</em></td>
|
|
<td align="left" valign="top">Too many descriptions for this process.<br>
|
|
<br>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top"><em>[ENFILE]</em></td>
|
|
<td align="left" valign="top">Too many descriptions 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>[EOPNOTSUPP]</em></td>
|
|
<td align="left" valign="top">Operation not supported.<br>
|
|
<br>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top"><em>[EPROTONOSUPPORT]</em></td>
|
|
<td align="left" valign="top">No protocol of the specified type and domain
|
|
exists.<br>
|
|
<br>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top"><em>[ESOCKTNOSUPPORT]</em></td>
|
|
<td align="left" valign="top">The specified socket type is not supported.<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">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 &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>The socket address families and types supported by sockets are defined in
|
|
<strong><sys/socket.h></strong>.<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>socketpair()</em> API is mapped to
|
|
<em>qso_socketpair98()</em>.
|
|
<br><br></li>
|
|
<li>If this function is called
|
|
by a thread executing one of the scan-related exit programs (or any of its
|
|
created threads),
|
|
<img src="delta.gif" alt="Start of change">
|
|
it will fail with error code [ENOTSUP].
|
|
<img src="deltaend.gif" alt="End of change">
|
|
See
|
|
<a href="ifsopenexit.htm">Integrated File System Scan on Open Exit Programs</a>
|
|
and <a href="ifscloseexit.htm">Integrated File System Scan on Close Exit
|
|
Programs</a> for more information.
|
|
</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="socket.htm">socket()</a>--Create Socket</li>
|
|
</ul>
|
|
|
|
<br>
|
|
<hr>
|
|
<p>API introduced: V3R1<br>
|
|
</p>
|
|
|
|
<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>
|
|
|