Converts short integers from host byte order to network byte
order.
Format
#include <in.h>
unsigned short int htons ( unsigned short int hostshort );
1 – Argument
hostshort
A short integer in host byte order (OpenVMS systems). All
short integers on OpenVMS systems are in host byte order unless
otherwise specified.
2 – Description
This function converts 16-bit unsigned integers from host byte
order to network byte order.
Data bytes transmitted over the network are expected to be
in network byte order. Some hosts, like OpenVMS, have an
internal data representation format that is different from the
network byte order; this is called the host byte order. Network
byte order places the byte with the most significant bits at
lower addresses, but OpenVMS host byte order places the most
significant bits at the highest address.
This function is most often used with ports returned by the
getservent() function. To convert port numbers from OpenVMS host
byte order to network byte order, use the htons() function.
NOTE
The 64-bit return from OpenVMS Alpha and I64 systems has
zero-extended bits in the high 32 bits of R0.
3 – Return Value
x A short integer in network byte order.
Integers in network byte order cannot be used
for arithmetic computation on OpenVMS systems.