1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
3 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .\" References consulted:
6 .\" Linux libc source code
7 .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
9 .\" Modified Sat Jul 24 21:29:05 1993 by Rik Faith (faith@cs.unc.edu)
10 .\" Modified Thu Jul 26 14:06:20 2001 by Andries Brouwer (aeb@cwi.nl)
12 .TH BYTEORDER 3 2021-03-22 "Linux man-pages (unreleased)" "Linux Programmer's Manual"
14 htonl, htons, ntohl, ntohs \- convert values between host and network
18 .RI ( libc ", " \-lc )
21 .B #include <arpa/inet.h>
23 .BI "uint32_t htonl(uint32_t " hostlong );
24 .BI "uint16_t htons(uint16_t " hostshort );
26 .BI "uint32_t ntohl(uint32_t " netlong );
27 .BI "uint16_t ntohs(uint16_t " netshort );
32 function converts the unsigned integer
34 from host byte order to network byte order.
38 function converts the unsigned short integer
40 from host byte order to network byte order.
44 function converts the unsigned integer
46 from network byte order to host byte order.
50 function converts the unsigned short integer
52 from network byte order to host byte order.
54 On the i386 the host byte order is Least Significant Byte first,
55 whereas the network byte order, as used on the Internet, is Most
56 Significant Byte first.
58 For an explanation of the terms used in this section, see
66 Interface Attribute Value
72 T} Thread safety MT-Safe
78 POSIX.1-2001, POSIX.1-2008.
82 .BR gethostbyname (3),