Commit | Line | Data |
---|---|---|
968d6b3e KB |
1 | .\" Copyright (c) 1983 The Regents of the University of California. |
2 | .\" All rights reserved. | |
96af7611 | 3 | .\" |
91cff1e1 | 4 | .\" %sccs.include.redist.man% |
96af7611 | 5 | .\" |
5904c8d5 | 6 | .\" @(#)byteorder.3 6.6 (Berkeley) %G% |
968d6b3e KB |
7 | .\" |
8 | .TH BYTEORDER 3 "" | |
96af7611 KM |
9 | .UC 5 |
10 | .SH NAME | |
11 | htonl, htons, ntohl, ntohs \- convert values between host and network byte order | |
12 | .SH SYNOPSIS | |
13 | .nf | |
5904c8d5 | 14 | .B #include <sys/param.h> |
96af7611 KM |
15 | .PP |
16 | .B netlong = htonl(hostlong); | |
17 | .B u_long netlong, hostlong; | |
18 | .PP | |
19 | .B netshort = htons(hostshort); | |
20 | .B u_short netshort, hostshort; | |
21 | .PP | |
22 | .B hostlong = ntohl(netlong); | |
23 | .B u_long hostlong, netlong; | |
24 | .PP | |
25 | .B hostshort = ntohs(netshort); | |
26 | .B u_short hostshort, netshort; | |
27 | .fi | |
28 | .SH DESCRIPTION | |
29 | These routines convert 16 and 32 bit quantities between network | |
5904c8d5 KB |
30 | byte order and host byte order. |
31 | On machines which have a byte order which is the same as the network | |
32 | order, routines are defined as null macros. | |
96af7611 KM |
33 | .PP |
34 | These routines are most often used in conjunction with Internet | |
35 | addresses and ports as returned by | |
968d6b3e | 36 | .IR gethostbyname (3) |
96af7611 | 37 | and |
968d6b3e | 38 | .IR getservent (3). |
96af7611 | 39 | .SH "SEE ALSO" |
968d6b3e | 40 | gethostbyname(3), getservent(3) |
96af7611 KM |
41 | .SH BUGS |
42 | The VAX handles bytes backwards from most everyone else in | |
43 | the world. This is not expected to be fixed in the near future. |