1BYTEORDER(3)               Library Functions Manual               BYTEORDER(3)
2
3
4

NAME

6       htonl,  htons,  ntohl,  ntohs - convert values between host and network
7       byte order
8

LIBRARY

10       Standard C library (libc, -lc)
11

SYNOPSIS

13       #include <arpa/inet.h>
14
15       uint32_t htonl(uint32_t hostlong);
16       uint16_t htons(uint16_t hostshort);
17
18       uint32_t ntohl(uint32_t netlong);
19       uint16_t ntohs(uint16_t netshort);
20

DESCRIPTION

22       The htonl() function converts the unsigned integer hostlong  from  host
23       byte order to network byte order.
24
25       The htons() function converts the unsigned short integer hostshort from
26       host byte order to network byte order.
27
28       The ntohl() function converts the unsigned integer netlong from network
29       byte order to host byte order.
30
31       The  ntohs() function converts the unsigned short integer netshort from
32       network byte order to host byte order.
33
34       On the i386 the host  byte  order  is  Least  Significant  Byte  first,
35       whereas  the  network byte order, as used on the Internet, is Most Sig‐
36       nificant Byte first.
37

ATTRIBUTES

39       For an  explanation  of  the  terms  used  in  this  section,  see  at‐
40       tributes(7).
41
42       ┌────────────────────────────────────────────┬───────────────┬─────────┐
43Interface                                   Attribute     Value   
44       ├────────────────────────────────────────────┼───────────────┼─────────┤
45htonl(), htons(), ntohl(), ntohs()          │ Thread safety │ MT-Safe │
46       └────────────────────────────────────────────┴───────────────┴─────────┘
47

STANDARDS

49       POSIX.1-2008.
50

HISTORY

52       POSIX.1-2001.
53

SEE ALSO

55       bswap(3), endian(3), gethostbyname(3), getservent(3)
56
57
58
59Linux man-pages 6.05              2023-07-20                      BYTEORDER(3)
Impressum