1HTONL(3P) POSIX Programmer's Manual HTONL(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 htonl, htons, ntohl, ntohs — convert values between host and network
13 byte order
14
16 #include <arpa/inet.h>
17
18 uint32_t htonl(uint32_t hostlong);
19 uint16_t htons(uint16_t hostshort);
20 uint32_t ntohl(uint32_t netlong);
21 uint16_t ntohs(uint16_t netshort);
22
24 These functions shall convert 16-bit and 32-bit quantities between net‐
25 work byte order and host byte order.
26
27 On some implementations, these functions are defined as macros.
28
29 The uint32_t and uint16_t types are defined in <inttypes.h>.
30
32 The htonl() and htons() functions shall return the argument value con‐
33 verted from host to network byte order.
34
35 The ntohl() and ntohs() functions shall return the argument value con‐
36 verted from network to host byte order.
37
39 No errors are defined.
40
41 The following sections are informative.
42
44 None.
45
47 These functions are most often used in conjunction with IPv4 addresses
48 and ports as returned by gethostent() and getservent().
49
51 None.
52
54 None.
55
57 endhostent(), endservent()
58
59 The Base Definitions volume of POSIX.1‐2017, <arpa_inet.h>, <int‐
60 types.h>
61
63 Portions of this text are reprinted and reproduced in electronic form
64 from IEEE Std 1003.1-2017, Standard for Information Technology -- Por‐
65 table Operating System Interface (POSIX), The Open Group Base Specifi‐
66 cations Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of
67 Electrical and Electronics Engineers, Inc and The Open Group. In the
68 event of any discrepancy between this version and the original IEEE and
69 The Open Group Standard, the original IEEE and The Open Group Standard
70 is the referee document. The original Standard can be obtained online
71 at http://www.opengroup.org/unix/online.html .
72
73 Any typographical or formatting errors that appear in this page are
74 most likely to have been introduced during the conversion of the source
75 files to man page format. To report such errors, see https://www.ker‐
76 nel.org/doc/man-pages/reporting_bugs.html .
77
78
79
80IEEE/The Open Group 2017 HTONL(3P)