9.12. htons(), htonl(), ntohs(), ntohl()
Last updated
uint32_t some_long = 10;
uint16_t some_short = 20;
uint32_t network_byte_order;
// 轉換與傳送
network_byte_order = htonl(some_long);
send(s, &network_byte_order, sizeof(uint32_t), 0);
some_short == ntohs(htons(some_short)); // 這行判斷式為真