C++socket编程,数据转为网络字节序的问题htons

2025-03-20 22:52:56
推荐回答(2个)
回答1:

C语言只规定short <= int <=long int。具体还得看具体的编译器
htons() host to network short
htonl() host to network long
ntohl() network to host long
ntohs() network to host short

回答2:

uint32_t htonl(uint32_t hostlong);
uint16_t htons(uint16_t hostshort);
uint32_t ntohl(uint32_t netlog);
uint16_t ntohs(uint16_t netshort);

这种时候你man一下就好了啊