学习Linux Command-ntohs

名称

htonl,htons,ntohl,ntohs - 在主机和网络字节顺序之间转换值

概要

#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 );

描述

htonl()函数将主机字节顺序的无符号整数hostlong转换为网络字节顺序。

htons()函数将未签名的短整数主机从主机字节顺序转换为网络字节顺序。

ntohl()函数将网络字节顺序的无符号整数netlong转换为主机字节顺序。

ntohs()函数将无符号短整数netshort从网络字节顺序转换为主机字节顺序。

在i80x86上,主机字节顺序首先是最低有效字节,而互联网上使用的网络字节顺序首先是最高有效字节。

符合

BSD 4.3