htonl The htonl function converts a u_long from host to TCP/IP network byte order (which is big-endian).u_long htonl( u_long hostlong );============================================== htons The htons function converts a u_short from host to TCP/IP network byte order (which is big-endian).u_short htons( u_short hostshort );
htonl: This function converts a u_long from host to TCP/IP network byte order, which is big-endian.u_long htonl( u_long hostlong ); Parameters hostlong [in] 32-bit number in host byte order. Return Values This function returns the value in TCP/IP network byte order. htons: This function converts a u_short from host to TCP/IP network byte order, which is big-endian.u_short htons( u_short hostshort ); Parameters hostshort [in] 16-bit number in host byte order. Res This function takes a 16-bit number in host byte order and returns a 16-bit number in network byte order used in TCP/IP networks.Return Values This function returns the value in TCP/IP network byte order.msdn如上解释,都是转换网络字节序的。一个是16字节主机字节序,一个是32字节主机字节序。
The htonl function converts a u_long from host to TCP/IP network byte order (which is big-endian).u_long htonl(
u_long hostlong
);==============================================
htons
The htons function converts a u_short from host to TCP/IP network byte order (which is big-endian).u_short htons(
u_short hostshort
);
This function converts a u_long from host to TCP/IP network byte order, which is big-endian.u_long htonl(
u_long hostlong
);
Parameters
hostlong
[in] 32-bit number in host byte order.
Return Values
This function returns the value in TCP/IP network byte order.
htons:
This function converts a u_short from host to TCP/IP network byte order, which is big-endian.u_short htons(
u_short hostshort
);
Parameters
hostshort
[in] 16-bit number in host byte order.
Res
This function takes a 16-bit number in host byte order and returns a 16-bit number in network byte order used in TCP/IP networks.Return Values
This function returns the value in TCP/IP network byte order.msdn如上解释,都是转换网络字节序的。一个是16字节主机字节序,一个是32字节主机字节序。
htonl: 0x1248ABCD -> 0xCDAB4812
htons: 0x1248 -> 0x4812