convert values between host and network
These routines convert 16 and 32-bit quantities between different byte orderings.
functions convert quantities from host to network byte order while the
functions convert in the other direction.
The last letter (‘s’ or ‘l’) is a mnemonic for the traditional names for such quantities, short and long, respectively. Today, the C concept of short and long integers need not coincide with this traditional misunderstanding. 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), htobe64(3)
ntohs() functions conform to IEEE
Std 1003.1 (“POSIX.1”).
These functions appeared in 4.2BSD.
On the alpha, amd64, i386, and some mips and arm architectures, bytes are handled backwards from most everyone else in the world. This is not expected to be fixed in the near future.