htonl() — Translate address host to network long
Standards
Standards / Extensions | C or C++ | Dependencies |
---|---|---|
XPG4.2 |
both |
Format
XPG4.2
#define _XOPEN_SOURCE_EXTENDED 1
#include <arpa/inet.h>
in_addr_t htonl(in_addr_t hostlong);
SUSV3
#define _POSIX_C_SOURCE 200112L
#include <apar/inet.h>
uint32_t htonl(uint32_t hostlong);
Berkeley
Sockets
#define _OE_SOCKETS
#include <sys/types.h>
#include <arpa/inet.h>
#include <netinet/in.h>
unsigned long htonl(unsigned long a);
General description
The htonl()
function translates a long integer from host byte order to network
byte order.
- Parameter
- Description
- a
- The unsigned long integer to be put into network byte order.
- in_addr_t hostlong
- Is typed to the unsigned long integer to be put into network byte order.
Notes:
- For MVS™, host byte order and network byte order are the same.
- Since this function is implemented as a macro, you need one of the feature test macros and the inet header file.
Returned value
htonl() returns the translated long integer.