pthread_create(&threadDns, NULL, ThreadDNS, dnsThread[i])
may run many times?
|
if (listenSocket == -1) { |
|
struct sockaddr_in6 si_me; |
|
if ((listenSocket=socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP))==-1) { |
|
listenSocket = -1; |
|
return -1; |
|
} |
|
replySocket = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP); |
|
if (replySocket == -1) |
|
{ |
|
close(listenSocket); |
|
return -1; |
|
} |
|
int sockopt = 1; |
|
setsockopt(listenSocket, IPPROTO_IPV6, DSTADDR_SOCKOPT, &sockopt, sizeof sockopt); |
|
memset((char *) &si_me, 0, sizeof(si_me)); |
|
si_me.sin6_family = AF_INET6; |
|
si_me.sin6_port = htons(opt->port); |
|
si_me.sin6_addr = in6addr_any; |
|
if (bind(listenSocket, (struct sockaddr*)&si_me, sizeof(si_me))==-1) |
|
return -2; |
|
} |