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. How to avoid excessive UDP packet loss -- for your information
Forum Updated to NodeBB v4.3 + New Features

How to avoid excessive UDP packet loss -- for your information

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 2.8k 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.
  • S Offline
    S Offline
    serdef
    wrote on last edited by
    #1

    Hello,

    my application suffered from udp packet loss at busy moments.
    Of course udp is not reliable, I know, but it lost many packets
    that wireshark did see arrive on my pc.

    I found a simple solution for that, within qt :
    Since QT5.3, you can set this socket option : QAbstractSocket::ReceiveBufferSizeSocketOption
    I updated to QT5.3, and set the OS socket receive buffer to a huge 2M bytes :
    This solved the packet loss, the default receive buffer is probably quite small.
    See code below.

    ...
    socket->bind(QHostAddress::Any,portnr);
    socket->setSocketOption(QAbstractSocket::ReceiveBufferSizeSocketOption,2000000);
    connect(socket, SIGNAL(readyRead()), this, SLOT(readyRead()));
    ...

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Oh my, if I had found that out 2 months ago, it would have spared me some huge refactoring...

      anyway, this is a great find, thanks a lot for sharing.

      (Z(:^

      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