diff --git a/Net/include/Poco/Net/HostEntry.h b/Net/include/Poco/Net/HostEntry.h index a0fdcc6ad1..a3c1d61b10 100644 --- a/Net/include/Poco/Net/HostEntry.h +++ b/Net/include/Poco/Net/HostEntry.h @@ -48,9 +48,9 @@ class Net_API HostEntry /// Creates the HostEntry from the data in an addrinfo structure. #endif -#if defined(POCO_VXWORKS) HostEntry(const std::string& name, const IPAddress& addr); -#endif + /// Creates the HostEntry from pre defined data + HostEntry(const HostEntry& entry); /// Creates the HostEntry by copying another one. diff --git a/Net/src/DNS.cpp b/Net/src/DNS.cpp index 92b1a204e0..1cc5ab22f8 100644 --- a/Net/src/DNS.cpp +++ b/Net/src/DNS.cpp @@ -25,7 +25,6 @@ #include "Poco/Unicode.h" #include - #if defined(POCO_HAVE_LIBRESOLV) #include #endif @@ -83,6 +82,16 @@ HostEntry DNS::hostByName(const std::string& hostname, unsigned freeaddrinfo(pAI); return result; } +#if defined(POCO_OS_FAMILY_WINDOWS) + else if(rc == WSANO_DATA && hostname == "localhost") // no data record found and is local host + { + #if defined(POCO_HAVE_IPv6) + return HostEntry("localhost", Poco::Net::IPAddress("::1")); + #else + return HostEntry("localhost",Poco::Net::IPAddress("127.0.0.1")); +#endif // ipv6 + } +#endif // _WIN32 else { aierror(rc, hostname); @@ -132,6 +141,13 @@ HostEntry DNS::hostByAddress(const IPAddress& address, unsigned freeaddrinfo(pAI); return result; } +#if defined(POCO_OS_FAMILY_WINDOWS) + else if(rc == WSANO_DATA && address.isLoopback()) // no data record found and is local host + { + return HostEntry("localhost", address); + } +#endif // _WIN32 + else { aierror(rc, address.toString()); diff --git a/Net/src/HostEntry.cpp b/Net/src/HostEntry.cpp index b045d264f1..97b748bc11 100644 --- a/Net/src/HostEntry.cpp +++ b/Net/src/HostEntry.cpp @@ -103,8 +103,6 @@ HostEntry::HostEntry(struct addrinfo* ainfo) #endif // POCO_HAVE_IPv6 -#if defined(POCO_VXWORKS) - HostEntry::HostEntry(const std::string& name, const IPAddress& addr): _name(name) @@ -113,8 +111,6 @@ HostEntry::HostEntry(const std::string& name, const IPAddress& addr): } -#endif // POCO_VXWORKS - HostEntry::HostEntry(const HostEntry& entry): _name(entry._name),