Converts an unsigned short integer from host byte order to Internet network byte order.
ISODE Library (libisode.a)
#include <sys/types.h> #include <netinet/in.h>
unsigned short htons ( HostShort)
unsigned short HostShort;
The htons subroutine converts an unsigned short (16-bit) integer from host byte order to Internet network byte order.
The Internet network requires ports and addresses in network standard byte order. Use the htons subroutine to convert addresses and ports from their host integer representation to network standard byte order.
The htons subroutine is defined in the net/nh.h file as a macro.
All applications containing the htons subroutine must be compiled with _BSD set to a specific value. Acceptable values are 43 and 44. In addition, all socket applications must include the BSD libbsd.a library.
HostShort | Specifies a 16-bit integer in host byte order that is a host address or port. |
The htons subroutine returns a 16-bit integer in Internet network byte order (most significant byte first).
The htonl subroutine, ntohl subroutine, ntohs subroutine.
Sockets Overview in AIX 5L Version 5.2 Communications Programming Concepts.