HTON.3
资源名称:os_source.zip [点击查看]
上传用户:datang2001
上传日期:2007-02-01
资源大小:53269k
文件大小:1k
源码类别:
操作系统开发
开发平台:
C/C++
- .TH HTON 3
- .SH NAME
- hton, htons, htonl, ntohs, ntohl - host to network byte order conversion
- .SH SYNOPSIS
- .ft B
- .nf
- #define _MINIX_SOURCE 1
- #include <stddef.h>
- #include <sys/types.h>
- #include <net/hton.h>
- u16_t htons(u16_t fIhost_wordfP)
- u32_t htonl(u32_t fIhost_dwordfP)
- u16_t ntohs(u16_t fInetwork_wordfP)
- u32_t ntohl(u32_t fInetwork_dwordfP)
- u16_t HTONS(u16_t fIhost_wordfP)
- u32_t HTONL(u32_t fIhost_dwordfP)
- u16_t NTOHS(u16_t fInetwork_wordfP)
- u32_t NTOHL(u32_t fInetwork_dwordfP)
- .fi
- .ft R
- .SH DESCRIPTION
- These macros convert 16-bit and 32-bit quantities to and from the network
- byte order used by the TCP/IP protocols.
- The function of the macros is encoded in their name.
- .B H
- means host byte order,
- .B n
- means network byte order,
- .B s
- means a 16-bit quantity and
- .B l
- means a 32-bit quantity.
- Thus
- .B htons
- converts a 16-bit quantity from host byte order to network byte order.
- The difference between the lower case and upper case variants is that
- the lower case variants evaluate the argument at most once and the
- upper case variants can be used for constant folding.
- That is,
- .PP
- .RS
- htonl(f(x))
- .RE
- .PP
- will call f(x) at most once and
- .PP
- .RS
- HTONS(0x10)
- .RE
- .PP
- will be equivalent to 0x10 on a big-endian machine and 0x1000 on a
- little-endian machine.
- .SH "SEE ALSO"
- .BR ip (4).
- .SH AUTHOR
- Philip Homburg (philip@cs.vu.nl)