add cleandir
[unix-history] / usr / src / lib / libc / net / byteorder.3
CommitLineData
96af7611
KM
1.\" Copyright (c) 1983 Regents of the University of California.
2.\" All rights reserved. The Berkeley software License Agreement
3.\" specifies the terms and conditions for redistribution.
4.\"
fd9e847f 5.\" @(#)byteorder.3 6.2 (Berkeley) %G%
96af7611 6.\"
c0acf85c 7.TH BYTEORDER 3N ""
96af7611
KM
8.UC 5
9.SH NAME
10htonl, htons, ntohl, ntohs \- convert values between host and network byte order
11.SH SYNOPSIS
12.nf
13.B #include <sys/types.h>
14.B #include <netinet/in.h>
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
29These routines convert 16 and 32 bit quantities between network
30byte order and host byte order. On machines such as the SUN
31these routines are defined as null macros in the include file
32.RI < netinet/in.h >.
33.PP
34These routines are most often used in conjunction with Internet
35addresses and ports as returned by
fd9e847f 36.IR gethostbyname (3N)
96af7611
KM
37and
38.IR getservent (3N).
39.SH "SEE ALSO"
fd9e847f 40gethostbyname(3N),
96af7611
KM
41getservent(3N)
42.SH BUGS
43The VAX handles bytes backwards from most everyone else in
44the world. This is not expected to be fixed in the near future.