+ // Resolve both the host and service simultaneously
+ while (1)
+ {
+ 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;
+ }
+ bad_addr.insert(bad_addr.begin(), Host);
+ Owner->SetFailReason("ResolveFailure");
+ return _error->Error(_("Could not resolve '%s'"),Host.c_str());
+ }
+
+ if (Res == EAI_AGAIN)
+ {
+ Owner->SetFailReason("TmpResolveFailure");
+ return _error->Error(_("Temporary failure resolving '%s'"),
+ Host.c_str());
+ }
+ return _error->Error(_("Something wicked happened resolving '%s:%s' (%i - %s)"),
+ Host.c_str(),ServStr,Res,gai_strerror(Res));
+ }
+ break;
+ }
+