摘要:
typedef uint16_t in_port_t;// Internet address. --- IPV4typedef uint32_t in_addr_t;struct in_addr{ in_addr_t s_addr;};// IPv6 addressstruct in6_addr{ union { uint8_t __u6_addr8[16]; } __in6_u;}; // Structure describing an Internet socket address --- IPV4struct sockaddr_in{ __SOCKADDR_COMM... 阅读全文
摘要:
/*+------------------------------------------------------------------------+| 小端存储: 低地址存放低位数据; || 例: int型数 0x12 34 56 78 || | | || ... 阅读全文
摘要:
#include <arpa/inet.h>#include <stdbool.h>#include <stdio.h>inline bool is_little_endian(void){ int a = 1; return *(int *)&a == a;}// hton 和 ntoh 函数的代码完全相同uint32_t my_htonl(uint32_t hl){ if(is_little_endian()) { return *((unsigned char *)&hl ) << 24 | *((unsign... 阅读全文