/*
* Functions hton16 and hton32 convert the host
* representation of integer numbers into the network
* representation as defined in "Trivial Internet Protocol",
* section 2.1.
* ntoh32 and ntoh16 are reverse functions to hton32 and hton16.
*
* Adjust the following definitions for the particular
* hardware and C complier.
*/
#define hton16(n) (((uint16)(n) >> 8) | ((uint16)(n) << 8))
#define hton32(n) (ntoh16((uint32)(n) >> 16) | (ntoh16(n) << 16))
#define ntoh16(n) hton16(n)
#define ntoh32(n) hton32(n)
ntoh16 与 hton16
最新推荐文章于 2022-07-09 16:47:07 发布
本文介绍了将主机字节序转换为网络字节序的函数 hton16 和 hton32,以及相反操作的函数 ntoh16 和 ntoh32。这些函数对于实现网络通信中的数据格式统一至关重要。
1000

被折叠的 条评论
为什么被折叠?



