2 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
4 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
6 .\" References consulted:
7 .\" Linux libc source code
8 .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
10 .\" Modified Sat Jul 24 21:29:05 1993 by Rik Faith (faith@cs.unc.edu)
11 .\" Modified Thu Jul 26 14:06:20 2001 by Andries Brouwer (aeb@cwi.nl)
13 .TH BYTEORDER 3 (date) "Linux man-pages (unreleased)"
15 htonl, htons, ntohl, ntohs \- convert values between host and network
19 .RI ( libc ", " \-lc )
22 .B #include <arpa/inet.h>
24 .BI "uint32_t htonl(uint32_t " hostlong );
25 .BI "uint16_t htons(uint16_t " hostshort );
27 .BI "uint32_t ntohl(uint32_t " netlong );
28 .BI "uint16_t ntohs(uint16_t " netshort );
33 function converts the unsigned integer
35 from host byte order to network byte order.
39 function converts the unsigned short integer
41 from host byte order to network byte order.
45 function converts the unsigned integer
47 from network byte order to host byte order.
51 function converts the unsigned short integer
53 from network byte order to host byte order.
55 On the i386 the host byte order is Least Significant Byte first,
56 whereas the network byte order, as used on the Internet, is Most
57 Significant Byte first.
59 For an explanation of the terms used in this section, see
67 Interface Attribute Value
73 T} Thread safety MT-Safe
79 POSIX.1-2001, POSIX.1-2008.
83 .BR gethostbyname (3),