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

QHostAddress comparison operator seems to struggle with iOS network interfaces

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.4.3
    • Network
    • None
    • iOS/tvOS/watchOS

    Description

      We are tracking host addresses for which writing a datagram failed to skip them on the next broadcast attempt. For doing so, a QVector<QHostAddress> is used. When removing entries from this vector whenever a datagram was written successfully, we noticed some strange behaviour. The comparison operator QHostAddress::operator== returns true for addresses which seem to be different. A string comparion of QHostAddress::toString() returns false for these occurrences.

      See the snippet below for which addresses/interface this happens:

       operator== says true but toString() comparison says false for QHostAddress("ff02::1%utun3") QHostAddress("ff02::1%lo0")
       operator== says true but toString() comparison says false for QHostAddress("ff02::1%utun3") QHostAddress("ff02::1%anpi0")
       operator== says true but toString() comparison says false for QHostAddress("ff02::1%utun3") QHostAddress("ff02::1%en2")
       operator== says true but toString() comparison says false for QHostAddress("ff02::1%utun3") QHostAddress("ff02::1%utun0")
       operator== says true but toString() comparison says false for QHostAddress("ff02::1%utun3") QHostAddress("ff02::1%en0")
       operator== says true but toString() comparison says false for QHostAddress("ff02::1%utun3") QHostAddress("ff02::1%awdl0")
       operator== says true but toString() comparison says false for QHostAddress("ff02::1%utun3") QHostAddress("ff02::1%llw0")
       operator== says true but toString() comparison says false for QHostAddress("ff02::1%utun3") QHostAddress("ff02::1%utun1")
       operator== says true but toString() comparison says false for QHostAddress("ff02::1%utun3") QHostAddress("ff02::1%utun2")
      

      Is this behaviour to be expected?

      Minimal example:

      const QHostAddress left("ff02::1%utun3");
      const QHostAddress right("ff02::1%lo0f");
      qDebug() << "operator==" << (left == right);
      qDebug() << "toString() comparison" << (left.toString() == right.toString());
      

      The addresses are retrieved via QNetworkInterface::allInterfaces() and QNetworkInterface::allAddresses().

      Attachments

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

        Activity

          People

            manordheim Mårten Nordheim
            janmoeller Jan Möller
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes