Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-27641

Multicast joining fails on multiple interfaces

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3: Somewhat important
    • Resolution: Done
    • Affects Version/s: 4.8.x, 5.7.0
    • Fix Version/s: 5.9.0 Beta 2
    • Component/s: Network: Sockets
    • Labels:
      None
    • Environment:
      Windows, Linux

      Description

      When trying to use QUdpSocket::joinMulticastGroup with multiple interfaces it often fails under certain conditions.

      After looking into the source code of qnativesocketengine_*.cpp I found the following code that is actually incorrect:

                  QList<QNetworkAddressEntry> addressEntries = iface.addressEntries();
                  if (!addressEntries.isEmpty()) {
                      QHostAddress firstIP = addressEntries.first().ip();
                      mreq4.imr_interface.s_addr = htonl(firstIP.toIPv4Address());
                  } else {
                      d->setError(QAbstractSocket::NetworkError,
                                  QNativeSocketEnginePrivate::NetworkUnreachableErrorString);
                      return false;
                  }
      

      This code takes the first address from the list and assumes it is an IPv4 address (which might not be true).
      The proper approach would be to iterate through the list and check for IPv4 protocol:

      	QList<QNetworkAddressEntry> addressEntries = iface.addressEntries();
      		for (int i = 0; i < addressEntries.length(); i++) {
      			if (addressEntries[i].ip().protocol() == QAbstractSocket::IPv4Protocol) {
      				...
      				break;
      

        Attachments

          Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            Activity

              People

              Assignee:
              Eddy Edward Welbourne
              Reporter:
              dremon Dmitry Pankratov
              Votes:
              5 Vote for this issue
              Watchers:
              11 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Gerrit Reviews

                  There are no open Gerrit changes