Merge pull request #1445 from cryptoknight/ip_stable_sort

Use stable_sort to preserve order of IP addresses from DNS
This commit is contained in:
Günter Obiltschnig 2016-10-05 09:19:49 +02:00 committed by GitHub
commit d9c3c5270a

View File

@ -252,7 +252,7 @@ void SocketAddress::init(const std::string& hostAddress, Poco::UInt16 portNumber
{ {
#if defined(POCO_HAVE_IPv6) #if defined(POCO_HAVE_IPv6)
// if we get both IPv4 and IPv6 addresses, prefer IPv4 // if we get both IPv4 and IPv6 addresses, prefer IPv4
std::sort(addresses.begin(), addresses.end(), AFLT()); std::stable_sort(addresses.begin(), addresses.end(), AFLT());
#endif #endif
init(addresses[0], portNumber); init(addresses[0], portNumber);
} }