host byte order(主机字节序):指一台计算机在内存中存储多字节数据(如 16/32/64 位整数)时采用的字节排列顺序,通常为小端(little-endian)或大端(big-endian)。在网络编程中常与 network byte order(网络字节序,通常为大端)对比,用于说明是否需要做字节序转换。
/hoʊst baɪt ˈɔːrdər/
The integer is stored in host byte order.
这个整数以主机字节序存储。
Before sending the packet, convert the 32-bit value from host byte order to network byte order using htonl().
在发送数据包之前,用 htonl() 把 32 位数值从主机字节序转换为网络字节序。
该短语由 host(主机) + byte(字节) + order(顺序)构成,源自计算机网络与系统编程语境:不同硬件架构可能采用不同的字节排列方式,因此在跨平台通信(尤其是 TCP/IP)中需要明确“主机自己的字节序”,并通过标准函数进行转换以保证互操作性。
htonl(3), ntohl(3) 等)