[Interest] Proper way to handle QUdpSocket::writeDatagram when it returns TemporaryError
Ola Røer Thorsen
ola at silentwings.no
Tue Oct 8 23:09:18 CEST 2019
Hi all, I've got a thread in an application (Linux, Qt 5.13.0) which just
writes udp datagrams at a relatively high frequency (video streaming).
Sometimes the QUdpSocket::writeDatagram function returns -1 and the socket
error is "TemporaryError". Looking into the source code of the udp socket
class, it seems like the actual reason is that the OS returns EAGAIN which
means I need to try again.
The thread is a QThread running the default event loop.
What's the best way to handle this? Right now I just made a dumb loop
trying again and again with a short usleep inbetween until it finally ships
the datagram. I tried using waitForBytesWritten when getting the temporary
error before trying again, but that had no noticeable effect. Without a
sleep, this spinning loop might have some several 100 retries before it is
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Interest