1INET_ADDR(3P)              POSIX Programmer's Manual             INET_ADDR(3P)
2
3
4

PROLOG

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
11

NAME

13       inet_addr, inet_ntoa — IPv4 address manipulation
14

SYNOPSIS

16       #include <arpa/inet.h>
17
18       in_addr_t inet_addr(const char *cp);
19       char *inet_ntoa(struct in_addr in);
20

DESCRIPTION

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 thread-safe.
30
31       All  Internet  addresses  shall  be  returned  in  network order (bytes
32       ordered from left to right).
33
34       Values specified using IPv4 dotted decimal notation  take  one  of  the
35       following forms:
36
37       a.b.c.d   When four parts are specified, each shall be interpreted as a
38                 byte of data and assigned, from left to right,  to  the  four
39                 bytes of an Internet address.
40
41       a.b.c     When  a  three-part address is specified, the last part shall
42                 be interpreted as a 16-bit quantity and placed in the  right‐
43                 most  two bytes of the network address. This makes the three-
44                 part address format convenient for specifying Class B network
45                 addresses as "128.net.host".
46
47       a.b       When  a  two-part address is supplied, the last part shall be
48                 interpreted as a 24-bit quantity and placed in the  rightmost
49                 three  bytes  of the network address. This makes the two-part
50                 address format convenient  for  specifying  Class  A  network
51                 addresses as "net.host".
52
53       a         When  only  one  part  is  given,  the  value shall be stored
54                 directly in the network address without any  byte  rearrange‐
55                 ment.
56
57       All  numbers  supplied  as parts in IPv4 dotted decimal notation may be
58       decimal, octal, or hexadecimal, as  specified  in  the  ISO C  standard
59       (that  is, a leading 0x or 0X implies hexadecimal; otherwise, a leading
60       '0' implies octal; otherwise, the number is interpreted as decimal).
61

RETURN VALUE

63       Upon successful  completion,  inet_addr()  shall  return  the  Internet
64       address. Otherwise, it shall return (in_addr_t)(−1).
65
66       The  inet_ntoa() function shall return a pointer to the network address
67       in Internet standard dot notation.
68

ERRORS

70       No errors are defined.
71
72       The following sections are informative.
73

EXAMPLES

75       None.
76

APPLICATION USAGE

78       The return value of inet_ntoa() may point to static data  that  may  be
79       overwritten by subsequent calls to inet_ntoa().
80

RATIONALE

82       None.
83

FUTURE DIRECTIONS

85       None.
86

SEE ALSO

88       endhostent(), endnetent()
89
90       The Base Definitions volume of POSIX.1‐2008, <arpa_inet.h>
91
93       Portions  of  this text are reprinted and reproduced in electronic form
94       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
95       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
96       Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
97       cal  and  Electronics  Engineers,  Inc  and  The  Open Group.  (This is
98       POSIX.1-2008 with the 2013 Technical Corrigendum  1  applied.)  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.unix.org/online.html .
103
104       Any typographical or formatting errors that appear  in  this  page  are
105       most likely to have been introduced during the conversion of the source
106       files to man page format. To report such errors,  see  https://www.ker
107       nel.org/doc/man-pages/reporting_bugs.html .
108
109
110
111IEEE/The Open Group                  2013                        INET_ADDR(3P)
Impressum