htonl, htons, ntohl, ntohs - convert values between host and network byte
order
Standard C Library (libc, -lc)
#include <sys/types.h>
in_addr_t
htonl(in_addr_t host32);
in_port_t
htons(in_port_t host16);
in_addr_t
ntohl(in_addr_t net32);
in_port_t
ntohs(in_port_t net16);
These routines convert 16 and 32 bit quantities between network byte
order and host byte order. The types in_addr_t and in_port_t are defined
by X/Open as:
typedef u_int32_t in_addr_t;
typedef u_int16_t in_port_t;
On machines which have a byte order which is the same as the network
order, routines are defined as null macros.
These routines are most often used in conjunction with Internet addresses
and ports as returned by gethostbyname(3) and getservent(3).
gethostbyname(3), getservent(3)
The byteorder functions appeared in 4.2BSD.
The `l' and `s' suffixes in the names are not meaningful in machines
where long integers are not 32 bits.
BSD June 4, 1993 BSD
[ Back ] |