Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QUdpSocket data loss using threads
Qt 6.11 is out! See what's new in the release blog

QUdpSocket data loss using threads

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 748 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    akozak211
    wrote on last edited by
    #1

    Hi all,

    I have been using QUdpSocket for a while now and we have legacy code that reimplements QThread. I converted the code so that I have a QObject named UDPServer that is passed to a QThread and executes it's event loop. Everything there works great. The problem I face is that the device I am communicating with bursts data packets, so I can a large chunk of UDP packets in a short period of time. I get significant data loss even with a large UDP buffer (using WinSock setsockopt). Here is what the architecture looks like:

    QThread 1:
    Running the event loop for the UDPServer which contains the QUDPSocket

    QThread 2:
    Running the event loop for FileWriter (Basically writes the data to a file when signalled from the UDPServer)

    The UDPServer stores x number of data packets before signalling the FileWriter to write to a file. This is to decrease overhead and have burst writes. I basically toggle between two receive buffers and once one is full, send that off to be written.

    Here are my questions:
    In the UDPServer, the QUDPSocket readyReady signal is connected to slotReadReady(). In there we use the same code as the QUDOSocket example:

    @
    while( m_p_UDPSocket->hasPendingDatagrams() ) {
    // Process the data
    }
    @

    Is the while loop blocking the QUDPSocket from getting more data packets since it is in the same thread? Does anyone know of a good approach to a high performance QUDPSocket receiver?

    Thank you for taking the time to read all of this, it's a lot :)

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved