|
|
1.1 root 1: .\" Copyright (c) 1983 The Regents of the University of California.
2: .\" All rights reserved.
3: .\"
4: .\" Redistribution and use in source and binary forms are permitted provided
5: .\" that: (1) source distributions retain this entire copyright notice and
6: .\" comment, and (2) distributions including binaries display the following
7: .\" acknowledgement: ``This product includes software developed by the
8: .\" University of California, Berkeley and its contributors'' in the
9: .\" documentation or other materials provided with the distribution and in
10: .\" all advertising materials mentioning features or use of this software.
11: .\" Neither the name of the University nor the names of its contributors may
12: .\" be used to endorse or promote products derived from this software without
13: .\" specific prior written permission.
14: .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
15: .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
16: .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
17: .\"
18: .\" @(#)byteorder.3 6.5 (Berkeley) 6/23/90
19: .\"
20: .TH BYTEORDER 3 "June 23, 1990"
21: .UC 5
22: .SH NAME
23: htonl, htons, ntohl, ntohs \- convert values between host and network byte order
24: .SH SYNOPSIS
25: .nf
26: .B #include <machine/endian.h>
27: .PP
28: .B netlong = htonl(hostlong);
29: .B u_long netlong, hostlong;
30: .PP
31: .B netshort = htons(hostshort);
32: .B u_short netshort, hostshort;
33: .PP
34: .B hostlong = ntohl(netlong);
35: .B u_long hostlong, netlong;
36: .PP
37: .B hostshort = ntohs(netshort);
38: .B u_short hostshort, netshort;
39: .fi
40: .SH DESCRIPTION
41: These routines convert 16 and 32 bit quantities between network
42: byte order and host byte order. On machines such as the SUN
43: these routines are defined as null macros in the include file
44: .RI < netinet/in.h >.
45: .PP
46: These routines are most often used in conjunction with Internet
47: addresses and ports as returned by
48: .IR gethostbyname (3)
49: and
50: .IR getservent (3).
51: .SH "SEE ALSO"
52: gethostbyname(3), getservent(3)
53: .SH BUGS
54: The VAX handles bytes backwards from most everyone else in
55: the world. This is not expected to be fixed in the near future.
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.