htonl()--Convert Long Integer to Network Byte Order
BSD 4.3 Syntax
#include <sys/types.h>
#include <netinet/in.h>
unsigned long htonl(unsigned long host_long)
Threadsafe: Yes
UNIX 98 Compatible Syntax
#define _XOPEN_SOURCE 520
#include <netinet/in.h>
uint32_t htonl(uint32_t host_long)
Threadsafe: Yes
The htonl() function is used to convert a long (4-byte) integer
from the local host byte order to standard network byte order.
There are two versions of the API, as shown above. The base i5/OS API uses
BSD 4.3 structures and syntax. The other uses syntax and structures compatible
with the UNIX 98 programming interface specifications. You can select the UNIX
98 compatible interface with the _XOPEN_SOURCE macro.
Parameters
- host_long
- (Input) The 4-byte integer in local host byte order that is to be converted
to standard network byte order.
Authorities
No authorization is required.
Return Value
htonl() returns an integer. Possible values are:
- n (where n is the 4-byte integer in standard network byte order)
Usage Notes
- On the iSeries server, the value returned to the caller is the same as the
value that was passed to htonl(), since the local host byte order does
not differ from the standard network byte order.
Related Information
- _XOPEN_SOURCE--Using _XOPEN_SOURCE for the UNIX 98
compatible interface
- ntohl()--Convert Long Integer to Host Byte
Order
- htons()--Convert Short Integer to Network Byte
Order
- ntohs()--Convert Short Integer to Host Byte
Order
API introduced: V3R1