1INET_ADDR(3P) POSIX Programmer's Manual INET_ADDR(3P)
2
3
4
6 This manual page is part of the POSIX Programmer's Manual. The Linux
7 implementation of this interface may differ (consult the corresponding
8 Linux manual page for details of Linux behavior), or the interface may
9 not be implemented on Linux.
10
12 inet_addr, inet_ntoa - IPv4 address manipulation
13
15 #include <arpa/inet.h>
16
17 in_addr_t inet_addr(const char *cp);
18 char *inet_ntoa(struct in_addr in);
19
20
22 The inet_addr() function shall convert the string pointed to by cp, in
23 the standard IPv4 dotted decimal notation, to an integer value suitable
24 for use as an Internet address.
25
26 The inet_ntoa() function shall convert the Internet host address speciā
27 fied by in to a string in the Internet standard dot notation.
28
29 The inet_ntoa() function need not be reentrant. A function that is not
30 required to be reentrant is not required to be thread-safe.
31
32 All Internet addresses shall be returned in network order (bytes
33 ordered from left to right).
34
35 Values specified using IPv4 dotted decimal notation take one of the
36 following forms:
37
38 a.b.c.d
39 When four parts are specified, each shall be interpreted as a
40 byte of data and assigned, from left to right, to the four bytes
41 of an Internet address.
42
43 a.b.c When a three-part address is specified, the last part shall be
44 interpreted as a 16-bit quantity and placed in the rightmost two
45 bytes of the network address. This makes the three-part address
46 format convenient for specifying Class B network addresses as
47 "128.net.host" .
48
49 a.b When a two-part address is supplied, the last part shall be
50 interpreted as a 24-bit quantity and placed in the rightmost
51 three bytes of the network address. This makes the two-part
52 address format convenient for specifying Class A network
53 addresses as "net.host" .
54
55 a When only one part is given, the value shall be stored directly
56 in the network address without any byte rearrangement.
57
58
59 All numbers supplied as parts in IPv4 dotted decimal notation may be
60 decimal, octal, or hexadecimal, as specified in the ISO C standard
61 (that is, a leading 0x or 0X implies hexadecimal; otherwise, a leading
62 '0' implies octal; otherwise, the number is interpreted as decimal).
63
65 Upon successful completion, inet_addr() shall return the Internet
66 address. Otherwise, it shall return ( in_addr_t)(-1).
67
68 The inet_ntoa() function shall return a pointer to the network address
69 in Internet standard dot notation.
70
72 No errors are defined.
73
74 The following sections are informative.
75
77 None.
78
80 The return value of inet_ntoa() may point to static data that may be
81 overwritten by subsequent calls to inet_ntoa().
82
84 None.
85
87 None.
88
90 endhostent(), endnetent(), the Base Definitions volume of
91 IEEE Std 1003.1-2001, <arpa/inet.h>
92
94 Portions of this text are reprinted and reproduced in electronic form
95 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
96 -- Portable Operating System Interface (POSIX), The Open Group Base
97 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
98 Electrical and Electronics Engineers, Inc and The Open Group. In the
99 event of any discrepancy between this version and the original IEEE and
100 The Open Group Standard, the original IEEE and The Open Group Standard
101 is the referee document. The original Standard can be obtained online
102 at http://www.opengroup.org/unix/online.html .
103
104
105
106IEEE/The Open Group 2003 INET_ADDR(3P)