ntohl Subroutine
Purpose
Converts an unsigned long integer from Internet network standard byte order to host byte order.
Library
ISODE Library (libisode.a)
Syntax
#include <sys/types.h>
#include <netinet/in.h>
uint32_t NetLong;
Description
The ntohl subroutine converts an unsigned long (32-bit) integer from Internet network standard byte order to host byte order.
Receiving hosts require addresses and ports in host byte order. Use the ntohl subroutine to convert Internet addresses and ports to the host integer representation.
The ntohl subroutine is defined in the net/nh.h file as a null macro if the host byte order is same as the network byte order.
The ntohl subroutine is declared in the net/nh.h file as a function if the host byte order is not same as the network byte order.
All applications containing the ntohl subroutine must be compiled with the _BSD macro set to a specific value. Acceptable values are 43 and 44. In addition, all socket applications must include the BSD libbsd.a library.
Parameters
Item | Description |
---|---|
NetLong | Requires a 32-bit integer in network byte order. |
Return Values
The ntohl subroutine returns a 32-bit integer in host byte order.