void DNS::aierror(int code, const std::string& arg) { #if defined(POCO_HAVE_IPv6) switch (code) { case EAI_AGAIN: throw DNSException("Temporary DNS error while resolving", arg); case EAI_FAIL: throw DNSException("Non recoverable DNS error while resolving", arg); #if !defined(_WIN32) // EAI_NODATA and EAI_NONAME have the same value case EAI_NODATA: throw NoAddressFoundException(arg); #endif case EAI_NONAME: throw HostNotFoundException(arg); #if defined(EAI_SYSTEM) case EAI_SYSTEM: error(lastError(), arg); break; #endif #if defined(_WIN32) case WSANO_DATA: // may happen on XP throw HostNotFoundException(arg); #endif default: throw DNSException("EAI", NumberFormatter::format(code)); } #endif // POCO_HAVE_IPv6 }
IPAddress DNS::resolveOne(const std::string& address) { const HostEntry& entry = resolve(address); if (!entry.addresses().empty()) return entry.addresses()[0]; else throw NoAddressFoundException(address); }
void DNS::error(int code, const std::string& arg) { switch (code) { case POCO_ESYSNOTREADY: throw NetException("Net subsystem not ready"); case POCO_ENOTINIT: throw NetException("Net subsystem not initialized"); case POCO_HOST_NOT_FOUND: throw HostNotFoundException(arg); case POCO_TRY_AGAIN: throw DNSException("Temporary DNS error while resolving", arg); case POCO_NO_RECOVERY: throw DNSException("Non recoverable DNS error while resolving", arg); case POCO_NO_DATA: throw NoAddressFoundException(arg); default: throw IOException(NumberFormatter::format(code)); } }