1BYTEORDER(3)               Linux Programmer's Manual              BYTEORDER(3)
2
3
4

NAME

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

SYNOPSIS

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

DESCRIPTION

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 i386 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

ATTRIBUTES

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

CONFORMING TO

47       POSIX.1-2001, POSIX.1-2008.
48
49       Some  systems  require  the  inclusion  of  <netinet/in.h>  instead  of
50       <arpa/inet.h>.
51

SEE ALSO

53       bswap(3), endian(3), gethostbyname(3), getservent(3)
54

COLOPHON

56       This page is part of release 5.07 of the Linux  man-pages  project.   A
57       description  of  the project, information about reporting bugs, and the
58       latest    version    of    this    page,    can     be     found     at
59       https://www.kernel.org/doc/man-pages/.
60
61
62
63GNU                               2017-09-15                      BYTEORDER(3)
Impressum