  
      struct in_addr v;
      if (iface.isValid()) {
+@@ -878,6 +908,7 @@ qint64 QNativeSocketEnginePrivate::nativeSendDatagram(const char *data, qint64 l
+     struct sockaddr *sockAddrPtr = 0;
+     QT_SOCKLEN_T sockAddrSize = 0;
+ 
++#ifdef QT_HAS_IPV6
+     struct sockaddr_in6 sockAddrIPv6;
+     if (host.protocol() == QAbstractSocket::IPv6Protocol
+         || socketProtocol == QAbstractSocket::IPv6Protocol
+@@ -891,7 +922,9 @@ qint64 QNativeSocketEnginePrivate::nativeSendDatagram(const char *data, qint64 l
+         memcpy(&sockAddrIPv6.sin6_addr.s6_addr, &tmp, sizeof(tmp));
+         sockAddrSize = sizeof(sockAddrIPv6);
+         sockAddrPtr = (struct sockaddr *)&sockAddrIPv6;
+-    } else if (host.protocol() == QAbstractSocket::IPv4Protocol) {
++    } else
++#endif
++    if (host.protocol() == QAbstractSocket::IPv4Protocol) {
+         memset(&sockAddrIPv4, 0, sizeof(sockAddrIPv4));
+         sockAddrIPv4.sin_family = AF_INET;
+         sockAddrIPv4.sin_port = htons(port);
+@@ -945,9 +978,11 @@ bool QNativeSocketEnginePrivate::fetchConnectionParameters()
+         case AF_INET:
+             socketProtocol = QAbstractSocket::IPv4Protocol;
+             break;
++#ifdef QT_HAS_IPV6
+         case AF_INET6:
+             socketProtocol = QAbstractSocket::IPv6Protocol;
+             break;
++#endif
+         default:
+             socketProtocol = QAbstractSocket::UnknownNetworkLayerProtocol;
+             break;
+@@ -958,6 +993,7 @@ bool QNativeSocketEnginePrivate::fetchConnectionParameters()
+         return false;
+     }
+ 
++#ifdef QT_HAS_IPV6
+ #if defined (IPV6_V6ONLY)
+     // determine if local address is dual mode
+     // On linux, these are returned as "::" (==AnyIPv6)
+@@ -976,6 +1012,7 @@ bool QNativeSocketEnginePrivate::fetchConnectionParameters()
+             }
+     }
+ #endif
++#endif
+ 
+     // Determine the remote address
+     if (!::getpeername(socketDescriptor, &sa.a, &sockAddrSize))

 QNetworkInterface QNativeSocketEnginePrivate::nativeMulticastInterface() const
 {
+#ifdef QT_HAS_IPV6
     if (socketProtocol == QAbstractSocket::IPv6Protocol) {
         uint v;
         QT_SOCKOPTLEN_T sizeofv = sizeof(v);
@@ -756,6 +777,7 @@
             return QNetworkInterface();
         return QNetworkInterface::interfaceFromIndex(v);
     }

 
     struct in_addr v = { 0 };
     QT_SOCKOPTLEN_T sizeofv = sizeof(v);
@@ -746,10 +774,12 @@ QNetworkInterface QNativeSocketEnginePrivate::nativeMulticastInterface() const
 
 bool QNativeSocketEnginePrivate::nativeSetMulticastInterface(const QNetworkInterface &iface)
 {
+#ifdef QT_HAS_IPV6
     if (socketProtocol == QAbstractSocket::IPv6Protocol || socketProtocol == QAbstractSocket::AnyIPProtocol) {
         uint v = iface.index();
         return (::setsockopt(socketDescriptor, IPPROTO_IPV6, IPV6_MULTICAST_IF, &v, sizeof(v)) != -1);
     }
