htonl(), htons(), ntohl(), ntohs() - convert values between host and network byte order
#include <arpa/inet.h>
in_addr_t htonl (unsigned long hostlong)
in_port_t htons (unsigned short hostshort)
in_addr_t ntohl (unsigned long netlong)
in_port_t ntohs (unsigned short netshort)
These routines convert 16 and 32 bit quantities between network byte order and host byte order.
These routines are most often used in conjunction with Internet addresses and ports as returned by gethostbyname(2).
The htons(3) and ntohs(3) functions must have the correct prototype. If not declared, they are assumed to return an int, and there is no guarantee that the high word will be zeroed.