From: Shane Kearns Date: Fri, 17 Feb 2012 20:33:57 +0000 (+0000) Subject: Windows - fix connecting to a socket using IPv4 mapped IPv6 X-Git-Tag: qt-v5.0.0-alpha1~921 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4bb020f50b5cc8656a17b217c04e662d88cb795c;p=profile%2Fivi%2Fqtbase.git 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 Reviewed-by: Thiago Macieira --- diff --git a/src/network/socket/qnativesocketengine_win.cpp b/src/network/socket/qnativesocketengine_win.cpp index e57bfcb..d7bbe7e 100644 --- a/src/network/socket/qnativesocketengine_win.cpp +++ b/src/network/socket/qnativesocketengine_win.cpp @@ -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) {