]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/byteorder.3
All pages: Replace the 4th argument to .TH by "Linux man-pages (unreleased)"
[thirdparty/man-pages.git] / man3 / byteorder.3
1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2 .\"
3 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
4 .\"
5 .\" References consulted:
6 .\" Linux libc source code
7 .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
8 .\" 386BSD man pages
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)
11 .\"
12 .TH BYTEORDER 3 2021-03-22 "Linux man-pages (unreleased)" "Linux Programmer's Manual"
13 .SH NAME
14 htonl, htons, ntohl, ntohs \- convert values between host and network
15 byte order
16 .SH LIBRARY
17 Standard C library
18 .RI ( libc ", " \-lc )
19 .SH SYNOPSIS
20 .nf
21 .B #include <arpa/inet.h>
22 .PP
23 .BI "uint32_t htonl(uint32_t " hostlong );
24 .BI "uint16_t htons(uint16_t " hostshort );
25 .PP
26 .BI "uint32_t ntohl(uint32_t " netlong );
27 .BI "uint16_t ntohs(uint16_t " netshort );
28 .fi
29 .SH DESCRIPTION
30 The
31 .BR htonl ()
32 function converts the unsigned integer
33 .I hostlong
34 from host byte order to network byte order.
35 .PP
36 The
37 .BR htons ()
38 function converts the unsigned short integer
39 .I hostshort
40 from host byte order to network byte order.
41 .PP
42 The
43 .BR ntohl ()
44 function converts the unsigned integer
45 .I netlong
46 from network byte order to host byte order.
47 .PP
48 The
49 .BR ntohs ()
50 function converts the unsigned short integer
51 .I netshort
52 from network byte order to host byte order.
53 .PP
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.
57 .SH ATTRIBUTES
58 For an explanation of the terms used in this section, see
59 .BR attributes (7).
60 .ad l
61 .nh
62 .TS
63 allbox;
64 lbx lb lb
65 l l l.
66 Interface Attribute Value
67 T{
68 .BR htonl (),
69 .BR htons (),
70 .BR ntohl (),
71 .BR ntohs ()
72 T} Thread safety MT-Safe
73 .TE
74 .hy
75 .ad
76 .sp 1
77 .SH STANDARDS
78 POSIX.1-2001, POSIX.1-2008.
79 .SH SEE ALSO
80 .BR bswap (3),
81 .BR endian (3),
82 .BR gethostbyname (3),
83 .BR getservent (3)