src/network/socket/qnativesocketengine_unix.cpp
changeset 37 758a864f9613
parent 33 3e2da88830cd
equal deleted inserted replaced
36:ef0373b55136 37:758a864f9613
   350 
   350 
   351     if (addr.protocol() == QAbstractSocket::IPv6Protocol) {
   351     if (addr.protocol() == QAbstractSocket::IPv6Protocol) {
   352         memset(&sockAddrIPv6, 0, sizeof(sockAddrIPv6));
   352         memset(&sockAddrIPv6, 0, sizeof(sockAddrIPv6));
   353         sockAddrIPv6.sin6_family = AF_INET6;
   353         sockAddrIPv6.sin6_family = AF_INET6;
   354         sockAddrIPv6.sin6_port = htons(port);
   354         sockAddrIPv6.sin6_port = htons(port);
       
   355 
       
   356         QString scopeid = addr.scopeId();
       
   357         bool ok;
       
   358         sockAddrIPv6.sin6_scope_id = scopeid.toInt(&ok);
   355 #ifndef QT_NO_IPV6IFNAME
   359 #ifndef QT_NO_IPV6IFNAME
   356         sockAddrIPv6.sin6_scope_id = ::if_nametoindex(addr.scopeId().toLatin1().data());
   360         if (!ok)
   357 #else
   361             sockAddrIPv6.sin6_scope_id = ::if_nametoindex(scopeid.toLatin1());
   358         sockAddrIPv6.sin6_scope_id = addr.scopeId().toInt();
       
   359 #endif
   362 #endif
   360         Q_IPV6ADDR ip6 = addr.toIPv6Address();
   363         Q_IPV6ADDR ip6 = addr.toIPv6Address();
   361         memcpy(&sockAddrIPv6.sin6_addr.s6_addr, &ip6, sizeof(ip6));
   364         memcpy(&sockAddrIPv6.sin6_addr.s6_addr, &ip6, sizeof(ip6));
   362 
   365 
   363         sockAddrSize = sizeof(sockAddrIPv6);
   366         sockAddrSize = sizeof(sockAddrIPv6);
   560 #ifdef Q_OS_SYMBIAN
   563 #ifdef Q_OS_SYMBIAN
   561     int acceptedDescriptor = ::accept(socketDescriptor, 0, 0);
   564     int acceptedDescriptor = ::accept(socketDescriptor, 0, 0);
   562 #else
   565 #else
   563     int acceptedDescriptor = qt_safe_accept(socketDescriptor, 0, 0);
   566     int acceptedDescriptor = qt_safe_accept(socketDescriptor, 0, 0);
   564 #endif
   567 #endif
   565     //check if we have vaild descriptor at all
   568     //check if we have valid descriptor at all
   566     if(acceptedDescriptor > 0) {
   569     if(acceptedDescriptor > 0) {
   567         // Ensure that the socket is closed on exec*()
   570         // Ensure that the socket is closed on exec*()
   568         ::fcntl(acceptedDescriptor, F_SETFD, FD_CLOEXEC);
   571         ::fcntl(acceptedDescriptor, F_SETFD, FD_CLOEXEC);
   569     }
   572     }
   570 #ifdef Q_OS_SYMBIAN
   573 #ifdef Q_OS_SYMBIAN