2020-03-22 IP地址打印
2020-03-22 本文已影响0人
XiaDaIT
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);