1BYTEORDER(3) Linux Programmer's Manual BYTEORDER(3)
2
3
4
6 htonl, htons, ntohl, ntohs - convert values between host and network
7 byte order
8
10 #include <arpa/inet.h>
11
12 uint32_t htonl(uint32_t hostlong);
13
14 uint16_t htons(uint16_t hostshort);
15
16 uint32_t ntohl(uint32_t netlong);
17
18 uint16_t ntohs(uint16_t netshort);
19
21 The htonl() function converts the unsigned integer hostlong from host
22 byte order to network byte order.
23
24 The htons() function converts the unsigned short integer hostshort from
25 host byte order to network byte order.
26
27 The ntohl() function converts the unsigned integer netlong from network
28 byte order to host byte order.
29
30 The ntohs() function converts the unsigned short integer netshort from
31 network byte order to host byte order.
32
33 On the i80x86 the host byte order is Least Significant Byte first,
34 whereas the network byte order, as used on the Internet, is Most Sig‐
35 nificant Byte first.
36
38 POSIX.1-2001.
39
40 Some systems require the inclusion of <netinet/in.h> instead of
41 <arpa/inet.h>.
42
44 gethostbyname(3), getservent(3)
45
46
47
48BSD 1993-04-15 BYTEORDER(3)