PDA

View Full Version : QUdpSocket::writeDatagram claims to send but does not



oliverg
1st June 2011, 13:46
Hello everyone,
I have a strange problem with my QUdpSocket. It is used inside a QThread for both sending and receiving of datagrams.
Most of the time this works. But there are situations when writeDatagrams does return the correct number of bytes sent but no datagram is recorded with Wireshark and no response is received. The network is a simple test network with two clients only one being a Windows machine the other an embedded device.
errorString() returns "Unknown error". I am really puzzled by the fact that no outgoing data is recorded by Wireshark.
At first I assumed an error on my side because this behaviour is related to one special datagram. But this datagram differs from the ones sent before only by one byte. And writeDatagram() is called.

Any hints on what might go wrong here?

Regards,
Oliver

squidge
1st June 2011, 18:00
Well, UDP is meant to provide an unreliable service where datagrams may arrive out of order or go missing without notice. Typically its used by time sensitive services such as video and audio when you can't afford to be waiting around for packets and prefer to just miss frames out.

The QOS on a modern OS may even decide to not put such packets on the network, depending on network/system load.

If you require a reliable service, you should use TCP.