150 lines
5.2 KiB
HTML
150 lines
5.2 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<html>
|
|
<head>
|
|
<meta name="generator" content="HTML Tidy, see www.w3.org">
|
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
|
<link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 -->
|
|
<!-- Copyright (c) 2001 The Open Group, All Rights Reserved -->
|
|
<title>inet_addr</title>
|
|
</head>
|
|
<body bgcolor="white">
|
|
|
|
<basefont size="3"> <a name="inet_addr"></a> <a name="tag_03_278"></a><!-- inet_addr -->
|
|
<!--header start-->
|
|
<center><font size="2">The Open Group Base Specifications Issue 6<br>
|
|
IEEE Std 1003.1-2001<br>
|
|
Copyright © 2001 The IEEE and The Open Group, All Rights reserved.</font></center>
|
|
|
|
<!--header end-->
|
|
<hr size="2" noshade>
|
|
<h4><a name="tag_03_278_01"></a>NAME</h4>
|
|
|
|
<blockquote>inet_addr, inet_ntoa - IPv4 address manipulation</blockquote>
|
|
|
|
<h4><a name="tag_03_278_02"></a>SYNOPSIS</h4>
|
|
|
|
<blockquote class="synopsis">
|
|
<p><code><tt>#include <<a href="../basedefs/arpa/inet.h.html">arpa/inet.h</a>><br>
|
|
<br>
|
|
in_addr_t inet_addr(const char *</tt><i>cp</i><tt>);<br>
|
|
char *inet_ntoa(struct in_addr</tt> <i>in</i><tt>);<br>
|
|
</tt></code></p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_278_03"></a>DESCRIPTION</h4>
|
|
|
|
<blockquote>
|
|
<p>The <i>inet_addr</i>() function shall convert the string pointed to by <i>cp</i>, in the standard IPv4 dotted decimal notation,
|
|
to an integer value suitable for use as an Internet address.</p>
|
|
|
|
<p>The <i>inet_ntoa</i>() function shall convert the Internet host address specified by <i>in</i> to a string in the Internet
|
|
standard dot notation.</p>
|
|
|
|
<p>The <i>inet_ntoa</i>() function need not be reentrant. A function that is not required to be reentrant is not required to be
|
|
thread-safe.</p>
|
|
|
|
<p>All Internet addresses shall be returned in network order (bytes ordered from left to right).</p>
|
|
|
|
<p>Values specified using IPv4 dotted decimal notation take one of the following forms:</p>
|
|
|
|
<dl compact>
|
|
<dt><tt>a.b.c.d</tt></dt>
|
|
|
|
<dd>When four parts are specified, each shall be interpreted as a byte of data and assigned, from left to right, to the four bytes
|
|
of an Internet address.</dd>
|
|
|
|
<dt><tt>a.b.c</tt></dt>
|
|
|
|
<dd>When a three-part address is specified, the last part shall be interpreted as a 16-bit quantity and placed in the rightmost two
|
|
bytes of the network address. This makes the three-part address format convenient for specifying Class B network addresses as
|
|
<tt>"128.net.host"</tt> .</dd>
|
|
|
|
<dt><tt>a.b</tt></dt>
|
|
|
|
<dd>When a two-part address is supplied, the last part shall be interpreted as a 24-bit quantity and placed in the rightmost three
|
|
bytes of the network address. This makes the two-part address format convenient for specifying Class A network addresses as
|
|
<tt>"net.host"</tt> .</dd>
|
|
|
|
<dt><tt>a</tt></dt>
|
|
|
|
<dd>When only one part is given, the value shall be stored directly in the network address without any byte rearrangement.</dd>
|
|
</dl>
|
|
|
|
<p>All numbers supplied as parts in IPv4 dotted decimal notation may be decimal, octal, or hexadecimal, as specified in the
|
|
ISO C standard (that is, a leading 0x or 0X implies hexadecimal; otherwise, a leading <tt>'0'</tt> implies octal; otherwise,
|
|
the number is interpreted as decimal).</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_278_04"></a>RETURN VALUE</h4>
|
|
|
|
<blockquote>
|
|
<p>Upon successful completion, <i>inet_addr</i>() shall return the Internet address. Otherwise, it shall return (
|
|
<b>in_addr_t</b>)(-1).</p>
|
|
|
|
<p>The <i>inet_ntoa</i>() function shall return a pointer to the network address in Internet standard dot notation.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_278_05"></a>ERRORS</h4>
|
|
|
|
<blockquote>
|
|
<p>No errors are defined.</p>
|
|
</blockquote>
|
|
|
|
<hr>
|
|
<div class="box"><em>The following sections are informative.</em></div>
|
|
|
|
<h4><a name="tag_03_278_06"></a>EXAMPLES</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_278_07"></a>APPLICATION USAGE</h4>
|
|
|
|
<blockquote>
|
|
<p>The return value of <i>inet_ntoa</i>() may point to static data that may be overwritten by subsequent calls to
|
|
<i>inet_ntoa</i>().</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_278_08"></a>RATIONALE</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_278_09"></a>FUTURE DIRECTIONS</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_278_10"></a>SEE ALSO</h4>
|
|
|
|
<blockquote>
|
|
<p><a href="endhostent.html"><i>endhostent</i>()</a> , <a href="endnetent.html"><i>endnetent</i>()</a> , the Base Definitions
|
|
volume of IEEE Std 1003.1-2001, <a href="../basedefs/arpa/inet.h.html"><i><arpa/inet.h></i></a></p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_278_11"></a>CHANGE HISTORY</h4>
|
|
|
|
<blockquote>
|
|
<p>First released in Issue 6. Derived from the XNS, Issue 5.2 specification.</p>
|
|
</blockquote>
|
|
|
|
<div class="box"><em>End of informative text.</em></div>
|
|
|
|
<hr>
|
|
<hr size="2" noshade>
|
|
<center><font size="2"><!--footer start-->
|
|
UNIX ® is a registered Trademark of The Open Group.<br>
|
|
POSIX ® is a registered Trademark of The IEEE.<br>
|
|
[ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href=
|
|
"../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a>
|
|
]</font></center>
|
|
|
|
<!--footer end-->
|
|
<hr size="2" noshade>
|
|
</body>
|
|
</html>
|
|
|