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

UDP Multicast on Specific Network Interface

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P2: Important
    • 5.9
    • 5.8.0
    • Network
    • None
    • 4c367833b4c1776f01eff3d51472a9889c85e1c5

    Description

      I tried to use QUdpSocket->joinMulticastGroup(), supplying a specific QNetworkInterface for message receipt.

      It didn't work (my app wasn't receiving messages that wireshark was showing).

      The reason it didn't work is that there is a faulty assumption in the implementation of multicastMembershipHelper().. in qnativesocketengine_win.cpp.

      Specifically, the following clause, which relates only to IPv4... assumes that if there are multiple address entries for the interface that simply taking the first one and trying to convert it to an IPv4 address will do the job. However, it is now common for interfaces to have both IPv6 and IPv4 addresses in this list. If an IPv4 address comes first.. good, otherwise bad.. which was my experience.

       

      const QList<QNetworkAddressEntry> addressEntries = iface.addressEntries();
      if (!addressEntries.isEmpty()) {
          QHostAddress firstIP = addressEntries.first().ip();
          mreq4.imr_interface.s_addr = htonl(firstIP.toIPv4Address());

      There should be a loop over all addressEntries, checking for protocol == IPv4Protocol, and using the first IPv4 entry.

       

       

      Attachments

        Issue Links

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

          Activity

            People

              Eddy Edward Welbourne
              unique27 Michael Chapman
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes