ntohs(3) — Subroutines
OSF
NAME
ntohs − Converts an unsigned short (16-bit) integer from Internet network-byte order to host-byte order
LIBRARY
Standard C Library (libc.a)
SYNOPSIS
#include <netinet/in.h> unsigned short ntohs (
unsigned short netshort) ;
PARAMETERS
netshortSpecifies a 16-bit integer in host-byte order.
DESCRIPTION
The ntohs() (network-to-host short) function converts an unsigned short (16-bit) integer from Internet network-byte order to host-byte order.
The Internet network requires address and port reference data in network-byte order (most significant byte leftmost, least significant byte rightmost). You can use the ntohs() function to convert Internet network address and port data to host-byte ordered integers.
The ntohs() function is defined as a little-endian function in the netinet/in.h header file for machine environments where network-byte order and host-byte order are not identical.
RETURN VALUES
The ntohs() function returns a 16-bit short integer in host-byte order.