  QT_BEGIN_NAMESPACE
  
  #if defined QNATIVESOCKETENGINE_DEBUG
-@@ -223,20 +227,24 @@
+@@ -177,20 +181,24 @@ static void convertToLevelAndOption(QNativeSocketEngine::SocketOption opt,
          n = SO_KEEPALIVE;
          break;
      case QNativeSocketEngine::MulticastTtlOption:
 +#ifdef QT_HAS_IPV6
-         if (socketProtocol == QAbstractSocket::IPv6Protocol) {
+         if (socketProtocol == QAbstractSocket::IPv6Protocol || socketProtocol == QAbstractSocket::AnyIPProtocol) {
              level = IPPROTO_IPV6;
              n = IPV6_MULTICAST_HOPS;
          } else

 
     struct in_addr v;
     if (iface.isValid()) {

             struct sockaddr_in6 *ns;
             ns = state._u._ext.nsaddrs[0];
             // nsaddrs will be NULL if no nameserver is set in /etc/resolv.conf
diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp
index 8869d75..468bb6a 100644
--- a/src/network/socket/qnativesocketengine_unix.cpp
+++ b/src/network/socket/qnativesocketengine_unix.cpp
@@ -57,6 +57,10 @@
 
 #include <netinet/tcp.h>
 
