To be a better coder
分类: LINUX
2020-07-20 16:05:54
int net_is_validipv6(const char *hostname)
{
struct sockaddr_in6 addr;
if (!hostname) return -1;
if (strchr(hostname, '.')) return -1;//暂时排除::ffff:204.152.189.116
if (inet_pton(AF_INET6, hostname, &addr.sin6_addr) != 1) return -1;
return 0;
}