sa.ss_family=AF_INET6;
}
error=getnameinfo((struct sockaddr *)&sa,sizeof(sa),host,sizeof(host),NULL,0,0);
- if (error==0)
- {
+ if (error==EAI_AGAIN) {
+ /*
+ This is a temporary failure. According to the man page we should try again but
+ it doesn't say if the program should wait before trying again nor how many attempts
+ before it becomes a fatal error. I could find no clues on internet so I try once and
+ leave it at that. Considering the number of IP addresses to resolve and the absence
+ of serious consequences should some IP fail to be resolved properly, it is best
+ not waste too much time on this.
+ */
+ error=getnameinfo((struct sockaddr *)&sa,sizeof(sa),host,sizeof(host),NULL,0,0);
+ }
+ if (error==0) {
strncpy(ip,host,ip_len-1);
ip[ip_len-1]='\0';
} else {