Windows - fix connecting to a socket using IPv4 mapped IPv6
Connecting to an IPv4 mapped IPv6 address (e.g. ::FFFF:127.0.0.1) requires the IPV6_V6ONLY socket option to be cleared. This was causing tst_qtcpserver::ipv6ServerMapped autotest to fail. The same change is not required on MacOS X - the test passes there. Task-number: QTBUG-24351 Change-Id: I6c08b19f0daa12765da2d44792ffb17299322695 Reviewed-by: Markus Goetz <markus@woboq.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>bb10
parent
054114a459
commit
4bb020f50b
|
|
@ -615,6 +615,16 @@ bool QNativeSocketEnginePrivate::nativeConnect(const QHostAddress &address, quin
|
|||
|
||||
setPortAndAddress(&sockAddrIPv4, &sockAddrIPv6, port, address, &sockAddrPtr, &sockAddrSize);
|
||||
|
||||
#if defined (IPV6_V6ONLY)
|
||||
if (socketProtocol == QAbstractSocket::IPv6Protocol && address.toIPv4Address()) {
|
||||
//IPV6_V6ONLY option must be cleared to connect to a V4 mapped address
|
||||
if (QSysInfo::windowsVersion() >= QSysInfo::WV_6_0) {
|
||||
DWORD ipv6only = 0;
|
||||
ipv6only = ::setsockopt(socketDescriptor, IPPROTO_IPV6, IPV6_V6ONLY, (char*)&ipv6only, sizeof(ipv6only) );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
forever {
|
||||
int connectResult = ::WSAConnect(socketDescriptor, sockAddrPtr, sockAddrSize, 0,0,0,0);
|
||||
if (connectResult == SOCKET_ERROR) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue