make port constructor explicit; no longer prefer IPv4 addresses over IPv6 addresses

This commit is contained in:
Guenter Obiltschnig 2016-10-10 18:44:55 +02:00
parent 547553278c
commit 6195c97a86
2 changed files with 2 additions and 2 deletions

View File

@ -61,7 +61,7 @@ public:
SocketAddress(const IPAddress& hostAddress, Poco::UInt16 portNumber);
/// Creates a SocketAddress from an IP address and given port number.
SocketAddress(Poco::UInt16 port);
explicit SocketAddress(Poco::UInt16 port);
/// Creates a SocketAddress with unspecified (wildcard) IP address
/// and given port number.

View File

@ -250,7 +250,7 @@ void SocketAddress::init(const std::string& hostAddress, Poco::UInt16 portNumber
HostEntry::AddressList addresses = he.addresses();
if (addresses.size() > 0)
{
#if defined(POCO_HAVE_IPv6)
#if defined(POCO_HAVE_IPv6) && defined(POCO_SOCKETADDRESS_PREFER_IPv4)
// if we get both IPv4 and IPv6 addresses, prefer IPv4
std::stable_sort(addresses.begin(), addresses.end(), AFLT());
#endif