HTON.3
Upload User: jnzhq888
Upload Date: 2007-01-18
Package Size: 51694k
Code Size: 2k
Category:

OS Develop

Development Platform:

WINDOWS

  1. HTON(3)                   Minix Programmer's Manual                    HTON(3)
  2. NAME
  3.      hton, htons, htonl, ntohs, ntohl - host to network byte order conversion
  4. SYNOPSIS
  5.      #define _MINIX_SOURCE 1
  6.      #include <stddef.h>
  7.      #include <sys/types.h>
  8.      #include <net/hton.h>
  9.      u16_t htons(u16_t host_word)
  10.      u32_t htonl(u32_t host_dword)
  11.      u16_t ntohs(u16_t network_word)
  12.      u32_t ntohl(u32_t network_dword)
  13.      u16_t HTONS(u16_t host_word)
  14.      u32_t HTONL(u32_t host_dword)
  15.      u16_t NTOHS(u16_t network_word)
  16.      u32_t NTOHL(u32_t network_dword)
  17. DESCRIPTION
  18.      These macros convert 16-bit and 32-bit quantities to and from the network
  19.      byte  order  used by the TCP/IP protocols.  The function of the macros is
  20.      encoded in their name.  H means host byte order,  n  means  network  byte
  21.      order,  s  means  a  16-bit quantity and l means a 32-bit quantity.  Thus
  22.      htons converts a 16-bit quantity from host byte  order  to  network  byte
  23.      order.   The difference between the lower case and upper case variants is
  24.      that the lower case variants evaluate the argument at most once  and  the
  25.      upper case variants can be used for constant folding.  That is,
  26.           htonl(f(x))
  27.      will call f(x) at most once and
  28.           HTONS(0x10)
  29.      will be equivalent to 0x10 on  a  big-endian  machine  and  0x1000  on  a
  30.      little-endian machine.
  31. SEE ALSO
  32.      ip(4).
  33. AUTHOR
  34.      Philip Homburg (philip@cs.vu.nl)
  35.                                                                              1