- if (Res == EAI_SERVICE)
- return _error->Error("Could not resolve service '%s'",S);
-
- if (Res == EAI_NONAME)
- return _error->Error("Could not resolve '%s'",Host.c_str());
-
- return _error->Error("Something wicked happend resolving '%s/%s'",
- Host.c_str(),S);
+ int Res;
+ if ((Res = getaddrinfo(Host.c_str(),ServStr,&Hints,&LastHostAddr)) != 0 ||
+ LastHostAddr == 0)
+ {
+ if (Res == EAI_NONAME || Res == EAI_SERVICE)
+ {
+ if (DefPort != 0)
+ {
+ snprintf(ServStr,sizeof(ServStr),"%u",DefPort);
+ DefPort = 0;
+ continue;
+ }
+ return _error->Error("Could not resolve '%s'",Host.c_str());
+ }
+
+ if (Res == EAI_AGAIN)
+ return _error->Error("Temporary failure resolving '%s'",
+ Host.c_str());
+ return _error->Error("Something wicked happened resolving '%s:%s' (%i)",
+ Host.c_str(),ServStr,Res);
+ }
+ break;