/*
* 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)
分享到:
相关推荐
你是否遇到过,内存中的数据顺序颠倒 你存入1234,实际存储的是3412. 字节存储顺序: little-endian小端,big-endian大端 教程 主机序,网络序 hton,ntoh
例如,一个16位的数字0x1234,在大端模式下,其高字节0x12会存储在低地址,而低字节0x34会存储在高地址。 小端字节序则相反,它将最低有效字节(LSB,Least Significant Byte)放在最低地址。在小端模式下,同样...
例如,在网络传输中,TCP/IP协议规定使用网络字节序(Big Endian),因此在发送和接收数据时,可能需要进行字节序的转换,这一过程通常被称为“网络字节序到主机字节序”(网络到主机,NtoH)或“主机字节序到网络...
易语言套接字WEB服务器源码系统结构:ERecv,HTTP协议处理,取请求信息,返回文档类型,WSAStartup,socket,htons,inet_addr,bind,listen,accept,recv,WSACleanup,send,CreateThread,closesocket,lstrlen,...ntoa,ntoh