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

UDP Socket cannot send via (unbind) port.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.0.1
    • 5.0.0
    • Network: Sockets
    • None
    • Qt 5.0.0 X-compiled on Gentoo Linux for mingw64, Windows Vista 64Bit as test environment.
    • e3bd06426afce9773fa64afe1a9946647cdec181

    Description

      The broadcast sender example is not able to send via the (unbind) socket.

      This is the original code:
      QByteArray datagram = "Broadcast message " + QByteArray::number(messageNo);
      udpSocket->writeDatagram(datagram.data(), datagram.size(),
      QHostAddress::Broadcast, 45454);

      To show the problem, I changed the source like this:
      QByteArray datagram = "Broadcast message " + QByteArray::number(messageNo);
      if(1 == udpSocket>writeDatagram(datagram.data(), datagram.size(), QHostAddress::Broadcast, 45454))
      qDebug() << "error on write datagram";

      This Variant is working:
      if(!udpSocket->bind(QHostAddress::AnyIPv4, 12345))
      qDebug() << "error on bind";

      QByteArray datagram = "Broadcast message " + QByteArray::number(messageNo);
      if(1 == udpSocket>writeDatagram(datagram.data(), datagram.size(), QHostAddress::Broadcast, 45454))
      qDebug() << "error on write datagram";

      To make the example working, the port to bind to is unimportant.

      Attachments

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

        Activity

          People

            shkearns Shane Kearns
            dreyero Olaf Dreyer
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes