source: trunk/minix/man/man3/hton.3@ 9

Last change on this file since 9 was 9, checked in by Mattia Monga, 13 years ago

Minix 3.1.2a

File size: 1.4 KB
Line 
1.TH HTON 3
2.SH NAME
3hton, htons, htonl, ntohs, ntohl \- host to network byte order conversion
4.SH SYNOPSIS
5.ft B
6.nf
7#define _MINIX_SOURCE 1
8#include <stddef.h>
9#include <sys/types.h>
10
11#include <net/hton.h>
12
13u16_t htons(u16_t \fIhost_word\fP)
14u32_t htonl(u32_t \fIhost_dword\fP)
15u16_t ntohs(u16_t \fInetwork_word\fP)
16u32_t ntohl(u32_t \fInetwork_dword\fP)
17u16_t HTONS(u16_t \fIhost_word\fP)
18u32_t HTONL(u32_t \fIhost_dword\fP)
19u16_t NTOHS(u16_t \fInetwork_word\fP)
20u32_t NTOHL(u32_t \fInetwork_dword\fP)
21.fi
22.ft R
23.SH DESCRIPTION
24These macros convert 16-bit and 32-bit quantities to and from the network
25byte order used by the TCP/IP protocols.
26The function of the macros is encoded in their name.
27.B H
28means host byte order,
29.B n
30means network byte order,
31.B s
32means a 16-bit quantity and
33.B l
34means a 32-bit quantity.
35Thus
36.B htons
37converts a 16-bit quantity from host byte order to network byte order.
38The difference between the lower case and upper case variants is that
39the lower case variants evaluate the argument at most once and the
40upper case variants can be used for constant folding.
41That is,
42.PP
43.RS
44htonl(f(x))
45.RE
46.PP
47will call f(x) at most once and
48.PP
49.RS
50HTONS(0x10)
51.RE
52.PP
53will be equivalent to 0x10 on a big-endian machine and 0x1000 on a
54little-endian machine.
55.SH "SEE ALSO"
56.BR ip (4).
57.SH AUTHOR
58Philip Homburg (philip@cs.vu.nl)
59.\"
60.\" $PchId: hton.3,v 1.3 1996/02/22 21:10:01 philip Exp $
Note: See TracBrowser for help on using the repository browser.