156 lines
10 KiB
HTML
156 lines
10 KiB
HTML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!DOCTYPE html
|
|
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html lang="en-us" xml:lang="en-us">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
<meta name="security" content="public" />
|
|
<meta name="Robots" content="index,follow" />
|
|
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
|
|
<meta name="DC.Type" content="reference" />
|
|
<meta name="DC.Title" content="Use AF_UNIX_CCSID address family" />
|
|
<meta name="abstract" content="AF_UNIX_CCSID address family sockets have the same specifications as AF_UNIX address family sockets. They can be used for connection-oriented or connectionless and provide communications on the same system." />
|
|
<meta name="description" content="AF_UNIX_CCSID address family sockets have the same specifications as AF_UNIX address family sockets. They can be used for connection-oriented or connectionless and provide communications on the same system." />
|
|
<meta name="DC.Relation" scheme="URI" content="uaddrfam.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="xafunixccsidsrv.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="xafunixccsidcl.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="cafunixccsid.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="uafunix.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="../apiref/pns.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="../apis/recvfr.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="../apis/accept.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="../apis/gpeern.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="../apis/gsockn.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="../apis/recvms.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="../apis/close.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="../apis/socket.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="../apis/bind.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="../apis/unlink.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="../apis/listen.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="../apis/send.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="../apis/connec.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="../apis/recv.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="../apis/socketp.htm" />
|
|
<meta name="copyright" content="(C) Copyright IBM Corporation 2001, 2006" />
|
|
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 2001, 2006" />
|
|
<meta name="DC.Format" content="XHTML" />
|
|
<meta name="DC.Identifier" content="uafunixccsid" />
|
|
<meta name="DC.Language" content="en-us" />
|
|
<!-- 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. -->
|
|
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
|
|
<link rel="stylesheet" type="text/css" href="./ic.css" />
|
|
<title>Use AF_UNIX_CCSID address family</title>
|
|
</head>
|
|
<body id="uafunixccsid"><a name="uafunixccsid"><!-- --></a>
|
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
|
<h1 class="topictitle1">Use AF_UNIX_CCSID address family</h1>
|
|
<div><p>AF_UNIX_CCSID address family sockets have the same specifications
|
|
as AF_UNIX address family sockets. They can be used for connection-oriented
|
|
or connectionless and provide communications on the same system.</p>
|
|
<div class="section"><p>Before
|
|
working with AF_UNIX_CCSID socket application, you should be familiar with
|
|
the <strong>Qlg_Path_Name_T</strong> structure to determine the output format.</p>
|
|
<p>When working with an output address structure, such as one returned from <span class="apiname">accept()</span>, <span class="apiname">getsockname()</span>, <span class="apiname">getpeername()</span>, <span class="apiname">recvfrom()</span>, and <span class="apiname">recvmsg()</span>,
|
|
the application must examine the socket address structure (sockaddr_unc) to
|
|
determine its format. The sunc_format and sunc_qlg fields determine the output
|
|
format of the path name. But sockets do not necessarily use the same values
|
|
on output as the application used on input addresses. </p>
|
|
<p><br /><img src="rzab6503.gif" alt="Socket flow of events used in server and client AF_UNIX_CCSID address family example programs." /><br /></p>
|
|
</div>
|
|
<div class="section"><h4 class="sectiontitle">Socket flow of events: Server application that uses AF_UNIX_CCSID
|
|
address family</h4><p>The first example uses the following sequence of
|
|
function calls:</p>
|
|
<ol><li>The <span class="apiname">socket()</span> function returns a socket descriptor representing
|
|
an endpoint. The statement also identifies that the UNIX_CCSID address family
|
|
with the stream transport (SOCK_STREAM) are used for this socket. You can
|
|
also use the <span class="apiname">socketpair()</span> function to initialize a UNIX<sup>®</sup> socket.
|
|
<p>AF_UNIX or AF_UNIX_CCSID are the only address families to support the <span class="apiname">socketpair()</span> function.
|
|
The <span class="apiname">socketpair()</span> function returns two socket descriptors
|
|
that are unnamed and connected.</p>
|
|
</li>
|
|
<li>After the socket descriptor is created, the <span class="apiname">bind()</span> function
|
|
gets a unique name for the socket. <p>The name space for UNIX domain sockets
|
|
consists of path names. When a sockets program calls the <span class="apiname">bind()</span> function,
|
|
an entry is created in the file system directory. If the path name already
|
|
exists, the <span class="apiname">bind()</span> fails. Thus, a UNIX domain socket
|
|
program should always call an <span class="apiname">unlink()</span> functions to remove
|
|
the directory entry when it ends. </p>
|
|
</li>
|
|
<li>The <span class="apiname">listen()</span> allows the server to accept incoming
|
|
client connections. In this example, the backlog is set to 10. This means
|
|
that the system queues 10 incoming connection requests before the system starts
|
|
rejecting the incoming requests.</li>
|
|
<li>The server uses the <span class="apiname">accept()</span> function to accept an
|
|
incoming connection request. The <span class="apiname">accept()</span> call blocks indefinitely
|
|
waiting for the incoming connection to arrive.</li>
|
|
<li>The <span class="apiname">recv()</span> function receives data
|
|
from the client application. In this example, the client sends 250 bytes of
|
|
data over. Thus the SO_RCVLOWAT socket option can be used, specifying that <span class="apiname">recv()</span> is
|
|
not required to wake up until all 250 bytes of data have arrived.</li>
|
|
<li>The <span class="apiname">send()</span> function echoes the data back to the client.</li>
|
|
<li>The <span class="apiname">close()</span> function closes any open socket descriptors.</li>
|
|
<li>The <span class="apiname">unlink()</span> function removes the UNIX path name
|
|
from the file system.</li>
|
|
</ol>
|
|
</div>
|
|
<div class="section"><h4 class="sectiontitle">Socket flow of events: Client application that uses AF_UNIX_CCSID
|
|
address family</h4><p>The second example uses the following sequence of
|
|
function calls:</p>
|
|
<ol><li>The <span class="apiname">socket()</span> function returns a socket descriptor representing
|
|
an endpoint. The statement also identifies that the UNIX address family
|
|
with the stream transport (SOCK_STREAM) is used for this socket. The function
|
|
returns a socket descriptor representing an endpoint. You can also use the <span class="apiname">socketpair()</span> function
|
|
to initialize a UNIX socket. <p>AF_UNIX or AF_UNIX_CCSID are the only
|
|
address families to support the <span class="apiname">socketpair()</span> function.
|
|
The <span class="apiname">socketpair()</span> function returns two socket descriptors
|
|
that are unnamed and connected.</p>
|
|
</li>
|
|
<li>After the socket descriptor is received, the <span class="apiname">connect()</span> function
|
|
is used to establish a connection to the server.</li>
|
|
<li>The <span class="apiname">send()</span> function sends 250 bytes of data that are
|
|
specified in the server application with the SO_RCVLOWAT socket
|
|
option. </li>
|
|
<li>The <span class="apiname">recv()</span> function loops until all 250 bytes of the
|
|
data have arrived. </li>
|
|
<li>The <span class="apiname">close()</span> function closes any open socket descriptors.</li>
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<ul class="ullinks">
|
|
<li class="ulchildlink"><strong><a href="xafunixccsidsrv.htm">Example: Server application that uses AF_UNIX_CCSID address family</a></strong><br />
|
|
The sample programs use the AF_UNIX_CCSID address family.</li>
|
|
<li class="ulchildlink"><strong><a href="xafunixccsidcl.htm">Example: Client application that uses AF_UNIX_CCSID address family</a></strong><br />
|
|
The sample programs use the AF_UNIX_CCSID address family.</li>
|
|
</ul>
|
|
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="uaddrfam.htm" title="This topic includes sample programs that illustrate each of the socket address families.">Design applications with address families</a></div>
|
|
</div>
|
|
<div class="relref"><strong>Related reference</strong><br />
|
|
<div><a href="cafunixccsid.htm" title="The AF_UNIX_CCSID family is compatible with the AF_UNIX address family and has the same limitations.">AF_UNIX_CCSID address family</a></div>
|
|
<div><a href="uafunix.htm" title="The AF_UNIX address family (sockets using the AF_UNIX or AF_UNIX_CCSID address families) can be connection-oriented (type SOCK_STREAM) or they can be connectionless (type SOCK_DGRAM).">Use AF_UNIX address family</a></div>
|
|
</div>
|
|
<div class="relinfo"><strong>Related information</strong><br />
|
|
<div><a href="../apiref/pns.htm">Path name format</a></div>
|
|
<div><a href="../apis/recvfr.htm">recvfrom()</a></div>
|
|
<div><a href="../apis/accept.htm">accept()</a></div>
|
|
<div><a href="../apis/gpeern.htm">getpeername()</a></div>
|
|
<div><a href="../apis/gsockn.htm">getsockname()</a></div>
|
|
<div><a href="../apis/recvms.htm">recvmsg()</a></div>
|
|
<div><a href="../apis/close.htm">close()</a></div>
|
|
<div><a href="../apis/socket.htm">socket()</a></div>
|
|
<div><a href="../apis/bind.htm">bind()</a></div>
|
|
<div><a href="../apis/unlink.htm">unlink()</a></div>
|
|
<div><a href="../apis/listen.htm">listen()</a></div>
|
|
<div><a href="../apis/send.htm">send()</a></div>
|
|
<div><a href="../apis/connec.htm">connect()</a></div>
|
|
<div><a href="../apis/recv.htm">recv()</a></div>
|
|
<div><a href="../apis/socketp.htm">socketpair()</a></div>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html> |