Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP-UX Reference > B


HP-UX 11i Version 3: February 2007

Technical documentation

» Feedback
Content starts here

 » Table of Contents

 » Index


htonl(), htons(), ntohl(), ntohs() — convert values between host and network byte order


#include <netinet/in.h> _XOPEN_SOURCE_EXTENDED only #include <arpa/inet.h> unsigned long htonl(unsigned long hostlong); unsigned short htons(unsigned short hostshort); unsigned long ntohl(unsigned long netlong); unsigned short ntohs(unsigned short netshort);


These routines convert 16- and 32-bit quantities between network byte order and host byte order. On HP-UX systems, network and host byte orders are identical, so these routines are defined as null macros in the include file <netinet/in.h>. If _XOPEN_SOURCE_EXTENDED is defined then these routines are defined in the include file <arpa/inet.h>.

These routines are most often used in conjunction with Internet addresses and ports as returned by gethostent() and getservent() (see gethostent(3N) and getservent(3N)). Use these routines to write portable programs.


byteorder() was developed by the University of California, Berkeley.


byteorder(): XPG4

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1983-2007 Hewlett-Packard Development Company, L.P.