[ Next Article | Previous Article | Book Contents | Library Home | Legal | Search ]
Communications Technical Reference, Volume 2

ntohs Subroutine

Purpose

Converts an unsigned short integer from Internet network byte order to host byte order.

Library

ISODE Library (libisode.a)

Syntax

#include <sys/types.h>
#include <netinet/in.h>
unsigned short ntohs (NetShort)
unsigned short NetShort;

Description

The ntohs subroutine converts an unsigned short (16-bit) integer from Internet network byte order to the host byte order.

Receiving hosts require Internet addresses and ports in host byte order. Use the ntohs subroutine to convert Internet addresses and ports to the host integer representation.

The ntohs subroutine is defined in the net/nh.h file as a macro.

Parameters

NetShort Requires a 16-bit integer in network standard byte order.

Return Values

The ntohs subroutine returns the supplied integer in host byte order.

Implementation Specifics

The ntohs subroutine is part of Base Operating System (BOS) Runtime.

All applications containing the ntohs 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.

Related Information

The endhostent subroutine, endservent subroutine, gethostbyaddr subroutine, gethostbyname subroutine, getservbyname subroutine, getservbyport subroutine, getservent subroutine, htonl subroutine, htons subroutine, ntohl subroutine, sethostent subroutine, setservent subroutine.

Sockets Overview in AIX Version 4.3 Communications Programming Concepts.


[ Next Article | Previous Article | Book Contents | Library Home | Legal | Search ]