摘要:
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... 阅读全文
posted @ 2012-09-04 04:36
庄庄庄
阅读(393)
评论(0)
推荐(0)
摘要:
/*+------------------------------------------------------------------------+| 小端存储: 低地址存放低位数据; || 例: int型数 0x12 34 56 78 || | | || ... 阅读全文
posted @ 2012-09-04 01:07
庄庄庄
阅读(257)
评论(0)
推荐(0)
摘要:
#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... 阅读全文
posted @ 2012-09-04 01:07
庄庄庄
阅读(466)
评论(0)
推荐(0)
浙公网安备 33010602011771号