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

QUdpSocket readyRead emited twice

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2: Important
    • Resolution: Won't Do
    • Affects Version/s: 5.9.6, 5.11.1
    • Fix Version/s: None
    • Component/s: Network: Sockets
    • Labels:
      None
    • Environment:
      Windows 10
      QtCreator 4.6.2
      Qt 5.9
    • Platform/s:
      Windows

      Description

      I made a program that talks with another throuth QUdpSocket.
      The first uses bind() and the second uses connectToService(). The QUdpSocket is managed by a UdpDevice class.

      Both connect the readyRead signal to call a slot (in another class) that calls UdpDevice::readAll() conditionned by hasPendingDatagram() (cf. joined source files).

      The issue is : randomly, the readyRead signal is emited twice for one single datagram. So, after the datagram is processed, the second signal call again the reading slot. The slot does nothing because hasPendingDatagram() returns false. But the framework consider that like an unread datagram and stops to fire readyReady for the next incomming datagrams, as said in the documentation : "Note: An incoming datagram should be read when you receive the readyRead() signal, otherwise this signal will not be emitted for the next datagram."

      I have this problem when I try to upgrade to Qt 9.5.6 or Qt 11.1, but all works fine with Qt 5.5.1

      EDIT : I dont have any problem like this on Ubuntu 18.04 with Qt 5.9.6

      EDIT 2 : I joined a minimal test project. To test, run two instances of the project and, give a negative port number to bind the server side and the same positive port number to the client side. Then, send a command from the client side.

      Here the debug output for the server side :

      Udp state changed : QAbstractSocket::BoundState
      ReadyRead emited for 2777 : true
      Read from 2777
      Datagram : "testcommand"
      ReadyRead emited for 2777 : false
      Read from 2777
      

       

        Attachments

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

          Activity

            People

            • Assignee:
              tpochep Timur Pocheptsov
              Reporter:
              ludo Demissy Ludovic
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Gerrit Reviews

                There are no open Gerrit changes