htonl(3XN)
NAME
htonl, htons, ntohl, ntohs − convert values between host and network byte order
SYNOPSIS
cc [ flag ... ] file ... −lxnet [ library ... ]
#include <arpa/inet.h> in_addr_t htonl(in_addr_t hostlong); in_port_t htons(in_port_t hostshort); in_addr_t ntohl(in_addr_t netlong); in_port_t ntohs(in_port_t netshort);
DESCRIPTION
These functions convert 16-bit and 32-bit quantities between network byte order and host byte order.
RETURN VALUES
The htonl() and htons() functions return the argument value converted from host to network byte order.
The ntohl() and ntohs() functions return the argument value converted from network to host byte order.
ERRORS
No errors are defined.
USAGE
These functions are most often used in conjunction with Internet addresses and ports as returned by gethostent(3XN) and getservent(3XN).
On some architectures these functions are defined as macros that expand to the value of their argument.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
| MT-Level | MT-Safe |
SEE ALSO
endhostent(3XN), endservent(3XN), attributes(5), inet(5)
SunOS 5.6 — Last change: 16 May 1997