将主机数转换成无符号长整型的网络字节顺序。本函数将一个32位数从主机字节顺序转换成网络字节顺序。
将主机数转换成无符号长整型的网络字节顺序。本函数将一个32位数从主机字节顺序转换成网络字节顺序。
将主机数转换成无符号长整形的网络字节顺序。
#include
uint32_t htonl(uint32_t hostlong);
hostlong:主机字节顺序表达的32位数。
本函数将一个32位数从主机字节顺序转换成网络字节顺序。
htonl()返回一个网络字节顺序的值。
参见:
htons(),ntohl(),ntohs().
在Linux系统下:
#include
uint32_t htonl(uint32_t hostlong);
有些系统包含的头文件是 而不是 .
uint16_t htons(uint16_t hostshort);
uint32_t ntohl(uint32_t netlong);
uint16_t ntohs(uint16_t netshort);
网际协议在处理这些多字节整数时,使用大端字节序。
在主机本身就使用大端字节序时,这些函数通常被定义为空宏。
This function converts au_longfrom host to TCP/IP network byte order, which is big-endian.
u_long htonl(u_longhostlong);Parameters
hostlong 32-bit number in host byte order.Return Values
This function returns the value in TCP/IP network byte order.
Remarks
This function takes a 32-bit number in host byte order and returns a 32-bit number in the network byte order used in TCP/IP networks.
htonl,其实是host to network, l 的意思是返回类型是long