[ Bottom of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]

Technical Reference: Communications, Volume 2

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>


unsigned long htonl ( HostLong)
unsigned long 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 macro.

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

Parameters

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).

Related Information

The htons subroutine, ntohl subroutine, ntohs subroutine.

Sockets Overview in AIX 5L Version 5.2 Communications Programming Concepts.

[ Top of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]