Host byte order(主机字节序)指某台计算机在内存中存放多字节数据(如 16 位、32 位整数)时,字节排列的本地规则。常见的主机字节序有小端序(little-endian)和大端序(big-endian)。在网络编程中,常需要在主机字节序与网络字节序之间转换,以保证不同机器之间数据一致。
/hoʊst baɪt ˈɔːrdər/
The port number is stored in host byte order.
端口号以主机字节序存储。
When sending a 32-bit integer over the network, convert it from host byte order to network byte order to avoid endianness issues across different architectures.
当通过网络发送 32 位整数时,应先把它从主机字节序转换为网络字节序,以避免不同硬件架构之间因端序不同而产生的问题。
该术语由三部分组成:host(主机/本机计算机)+ byte(字节)+ order(顺序/排列)。它在网络与系统编程语境中固定化,用来强调“本机采用的字节排列方式”,并与统一规定的 network byte order(网络字节序,传统上为大端)相对。