htonl Subroutine

Purpose

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

Library

ISODE Library (libisode.a)

Syntax

#include <sys/types.h>
#include <netinet/in.h>

uint32_t htonl ( HostLong)
uint32_t HostLong;

Description

The htonl subroutine converts an unsigned long (32-bit) integer from host byte order to Internet network byte order.

The Internet network requires addresses and ports in network standard byte order. Use the htonl subroutine to convert the host integer representation of addresses and ports to Internet network byte order.

The htonl subroutine is defined in the net/nh.h file as a null macro if the host byte order is the same as the network byte order.

The htonl subroutine is declared in the net/nh.h file as a function if the host byte order is not the same as the network byte order.

All applications containing the htonl 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
HostLong Specifies a 32-bit integer in host byte order.

Return Values

The htonl subroutine returns a 32-bit integer in Internet network byte order (most significant byte first).