diff options
author | Shane Kearns <shane.kearns@accenture.com> | 2012-04-23 15:29:41 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-04-24 15:58:26 +0200 |
commit | 6137067fc2c746cf064e47767286292ebc3fbf2e (patch) | |
tree | f78a43710fd8aaa57eb452c3642c5e3755810901 /src/network/socket/qnativesocketengine_unix.cpp | |
parent | 20d901a5553087ee4acbd1f68e5b8f5cce9b24d3 (diff) |
Fix tst_qtcpserver::serverAddress on Mac OSX
While linux returns the local address of dual mode sockets as "::"
i.e. the IPv6 address, OSX returns "::FFFF:0.0.0.0" i.e. the IPv4 address.
In the unix socket engine, treat both of these as candidates for
being a dual mode socket. This should hopefully cover other unixes
which we haven't tested.
Task-Number: QTBUG-25445
Change-Id: If1251018d54da98618223ba538c00ba54ac4cb4e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/network/socket/qnativesocketengine_unix.cpp')
-rw-r--r-- | src/network/socket/qnativesocketengine_unix.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp index 7cd8e1bff3..91299f5f92 100644 --- a/src/network/socket/qnativesocketengine_unix.cpp +++ b/src/network/socket/qnativesocketengine_unix.cpp @@ -943,9 +943,13 @@ bool QNativeSocketEnginePrivate::fetchConnectionParameters() #if defined (IPV6_V6ONLY) // determine if local address is dual mode + // On linux, these are returned as "::" (==AnyIPv6) + // On OSX, these are returned as "::FFFF:0.0.0.0" (==AnyIPv4) + // in either case, the IPV6_V6ONLY option is cleared int ipv6only = 0; socklen_t optlen = sizeof(ipv6only); - if (localAddress == QHostAddress::AnyIPv6 + if (socketProtocol == QAbstractSocket::IPv6Protocol + && (localAddress == QHostAddress::AnyIPv4 || localAddress == QHostAddress::AnyIPv6) && !getsockopt(socketDescriptor, IPPROTO_IPV6, IPV6_V6ONLY, (char*)&ipv6only, &optlen )) { if (optlen != sizeof(ipv6only)) qWarning("unexpected size of IPV6_V6ONLY socket option"); |