HTONL(3XNET)HTONL(3XNET)NAME
htonl, htons, ntohl, ntohs - convert values between host and network
byte order
SYNOPSIS
cc [ flag ... ] file ... -lxnet [ library ... ]
#include <arpa/inet.h>
uint32_t htonl(uint32_t hostlong);
uint64_t htonll(uint64_t hostlonglong);
uint16_t htons(uint16_t hostshort);
uint32_t ntohl(uint32_t netlong);
uint64_t ntohll(uint64_t netlonglong);
uint16_t ntohs(uint16_t netshort);
DESCRIPTION
These functions convert 16-bit, 32-bit, and 64-bit quantities between
network byte order and host byte order.
The uint32_t, uint16_t, and uint64_t types are made available by inclu‐
sion of <inttypes.h>.
USAGE
These functions are most often used in conjunction with Internet
addresses and ports as returned by gethostent(3XNET) and getser‐
vent(3XNET).
On some architectures these functions are defined as macros that expand
to the value of their argument.
RETURN VALUES
The htonl(), htonll(), and htons() functions return the argument value
converted from host to network byte order.
The ntohl(), ntohll(), and ntohs() functions return the argument value
converted from network to host byte order.
ERRORS
No errors are defined.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
┌────────────────────┬─────────────────┐
│ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
├────────────────────┼─────────────────┤
│Interface Stability │ Standard │
├────────────────────┼─────────────────┤
│MT-Level │ MT-Safe │
└────────────────────┴─────────────────┘
SEE ALSOendhostent(3XNET), endservent(3XNET), attributes(5), standards(5)
Jan 03, 2013 HTONL(3XNET)