add cleandir
[unix-history] / usr / src / lib / libc / net / byteorder.3
... / ...
CommitLineData
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.\"
5.\" @(#)byteorder.3 6.2 (Berkeley) %G%
6.\"
7.TH BYTEORDER 3N ""
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
36.IR gethostbyname (3N)
37and
38.IR getservent (3N).
39.SH "SEE ALSO"
40gethostbyname(3N),
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.