struct in_addr sip4;
struct in6_addr sip6;
char ip[16] = {0}, ipv6[40] = {0};
inet_ntop(AF_INET, &sip4, ip, sizeof(ip));
printf("\tsip:%s", ip);
inet_ntop(AF_INET6, &sip6, ipv6, sizeof(ipv6));
printf("\tsip:%s", ipv6);
网友评论