Converts 16-bit quantities from host to network byte order.
#include <sys/byteorder.h> unsigned short htons ( unsigned short hostshort);
(IN) Specifies a 16-bit quantity in host byte order.
Returns a value that has been converted from host to network byte order.
The htons function is frequently used to convert port numbers from host byte order to network byte order for socket calls requiring a port number as a parameter.
NOTE:Network data order places the most significant byte at the lower memory address, while host data order places the least significant byte at the lower address.