ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzab6_5.4.0.1/socaddr.htm

122 lines
6.2 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="Socket address structure" />
<meta name="abstract" content="Sockets use the sockaddr address structure to pass and to receive addresses. This structure does not require the socket API to recognize the addressing format." />
<meta name="description" content="Sockets use the sockaddr address structure to pass and to receive addresses. This structure does not require the socket API to recognize the addressing format." />
<meta name="DC.Relation" scheme="URI" content="characteristics.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="socaddr" />
<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>Socket address structure </title>
</head>
<body id="socaddr"><a name="socaddr"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Socket address structure </h1>
<div><p>Sockets use the <strong>sockaddr</strong> address structure to pass and to
receive addresses. This structure does not require the socket API to recognize
the addressing format.</p>
<div class="section"><p>Currently i5/OS™ supports Berkeley Software Distribution (BSD)
4.3 and X/Open Single Unix Specification (UNIX<sup>®</sup> 98). The base i5/OS API uses BSD 4.3 structures and syntax.
You can select the UNIX 98 compatible interface by defining the _XOPEN_SOURCE
macro to a value of 520 or greater. Each socket address structure for BSD
4.3 that is used has an equivalent UNIX 98 structure.</p>
</div>
<div class="section"><div class="p">
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" frame="border" border="1" rules="all"><caption>Table 1. Comparison of BSD 4.3 and BSD 4.4/ UNIX 98 socket
address structure</caption><thead align="left"><tr><th valign="top" width="48.45360824742268%" id="d0e47">BSD 4.3 structure</th>
<th valign="top" width="51.546391752577314%" id="d0e49">BSD 4.4/ UNIX 98 compatible structure</th>
</tr>
</thead>
<tbody><tr><td valign="top" width="48.45360824742268%" headers="d0e47 "> <pre>struct sockaddr{
u_short sa_family;
char sa_data [14];
};</pre>
<pre>struct sockaddr_storage{
sa_family_t ss_family;
char _ss_pad1[_SS_PAD1SIZE];
char* _ss_align;
char _ss_pad2[_SS_PAD2SIZE];
};</pre>
</td>
<td valign="top" width="51.546391752577314%" headers="d0e49 "> <pre>struct sockaddr {
uint8_t sa_len;
sa_family_t sa_family
char sa_data[14]
};</pre>
<pre>struct sockaddr_storage {
uint8_t ss_len;
sa_family_t ss_family;
char _ss_pad1[_SS_PAD1SIZE];
char* _ss_align;
char _ss_pad2[_SS_PAD2SIZE];
};</pre>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="section"><div class="p">
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" frame="border" border="1" rules="all"><caption>Table 2. Address structure </caption><thead align="left"><tr><th valign="top" id="d0e81">Address structure field</th>
<th valign="top" id="d0e83">Definition</th>
</tr>
</thead>
<tbody><tr><td valign="top" headers="d0e81 ">sa_len</td>
<td valign="top" headers="d0e83 ">This field contains the length of the address for UNIX 98
specifications. <div class="note"><span class="notetitle">Note:</span> The: sa_len field is only provided for BSD 4.4 compatibility.
It is not necessary to use this field even when using BSD 4.4/UNIX 98 compatibility.
The field is ignored on input addresses.</div>
</td>
</tr>
<tr><td valign="top" headers="d0e81 ">sa_family</td>
<td valign="top" headers="d0e83 ">This field defines the address family. This value is
specified for the address family on the <span class="apiname">socket()</span> call.</td>
</tr>
<tr><td valign="top" headers="d0e81 ">sa_data </td>
<td valign="top" headers="d0e83 ">This field contains fourteen bytes that are reserved
to hold the address itself. <div class="note"><span class="notetitle">Note:</span> The sa_data length of 14 bytes is a placeholder
for the address. The address can exceed this length. The structure is generic
because it does not define the format of the address. The format of the address
is defined by the type of transport which a socket is created for. Each of
the transport providers define the exact format for its specific addressing
requirements in a similar address structure. The transport is identified by
the protocol parameter values on the <span class="apiname">socket()</span> API.</div>
</td>
</tr>
<tr><td valign="top" headers="d0e81 ">sockaddr_storage</td>
<td valign="top" headers="d0e83 ">Declares storage for any address family address. This
structure is large enough and aligned for any protocol-specific structure.
It can then be cast as sockaddr structure for use on the APIs. The ss_family
field of the sockaddr_storage always aligns with the family field
of any protocol-specific structure. </td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="characteristics.htm" title="Sockets share some common characteristics.">Socket characteristics</a></div>
</div>
</div>
</body>
</html>