mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-29 12:18:01 +01:00
fix for GH #1449: you can now compile Net with -DPOCO_SOCKETADDRESS_DONT_PREFER_IPV4 to prevent SocketAddress from preferring IPv4 over IPv6 addresses
This commit is contained in:
@@ -44,7 +44,7 @@ public:
|
|||||||
SocketAddress(const IPAddress& hostAddress, Poco::UInt16 portNumber);
|
SocketAddress(const IPAddress& hostAddress, Poco::UInt16 portNumber);
|
||||||
/// Creates a SocketAddress from an IP address and given port number.
|
/// 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
|
/// Creates a SocketAddress with unspecified (wildcard) IP address
|
||||||
/// and given port number.
|
/// and given port number.
|
||||||
|
|
||||||
|
|||||||
@@ -234,7 +234,7 @@ void SocketAddress::init(const std::string& hostAddress, Poco::UInt16 portNumber
|
|||||||
HostEntry::AddressList addresses = he.addresses();
|
HostEntry::AddressList addresses = he.addresses();
|
||||||
if (addresses.size() > 0)
|
if (addresses.size() > 0)
|
||||||
{
|
{
|
||||||
#if defined(POCO_HAVE_IPv6)
|
#if defined(POCO_HAVE_IPv6) && !defined(POCO_SOCKETADDRESS_DONT_PREFER_IPV4)
|
||||||
// if we get both IPv4 and IPv6 addresses, prefer IPv4
|
// if we get both IPv4 and IPv6 addresses, prefer IPv4
|
||||||
std::stable_sort(addresses.begin(), addresses.end(), AFLT());
|
std::stable_sort(addresses.begin(), addresses.end(), AFLT());
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user