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

NAME

12       inet_addr, inet_ntoa — IPv4 address manipulation
13

SYNOPSIS

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

DESCRIPTION

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

RETURN VALUE

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

ERRORS

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

EXAMPLES

74       None.
75

APPLICATION USAGE

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

RATIONALE

81       None.
82

FUTURE DIRECTIONS

84       None.
85

SEE ALSO

87       endhostent(), endnetent()
88
89       The Base Definitions volume of POSIX.1‐2017, <arpa_inet.h>
90
92       Portions  of  this text are reprinted and reproduced in electronic form
93       from IEEE Std 1003.1-2017, Standard for Information Technology --  Por‐
94       table  Operating System Interface (POSIX), The Open Group Base Specifi‐
95       cations Issue 7, 2018 Edition, Copyright (C) 2018 by the  Institute  of
96       Electrical  and  Electronics Engineers, Inc and The Open Group.  In the
97       event of any discrepancy between this version and the original IEEE and
98       The  Open Group Standard, the original IEEE and The Open Group Standard
99       is the referee document. The original Standard can be  obtained  online
100       at http://www.opengroup.org/unix/online.html .
101
102       Any  typographical  or  formatting  errors that appear in this page are
103       most likely to have been introduced during the conversion of the source
104       files  to  man page format. To report such errors, see https://www.ker
105       nel.org/doc/man-pages/reporting_bugs.html .
106
107
108
109IEEE/The Open Group                  2017                        INET_ADDR(3P)
Impressum