[Interest] Q(Tcp/Udp)Socket stall

Nuno Santos nunosantos at imaginando.pt
Fri Apr 24 13:01:10 CEST 2015


Hi,

I have passed the last 48 hours trying to understand a problem I was having with sockets. I was driving crazy but I think I finally reached a conclusion. Let me summarize:

- Program A that sends data via sockets to localhost
- Program B, built in Qt, receives data via QUdpSocket (I have also tried with QTcpSocket and the problem is the same).

Program A sends constant size messages (76 bytes) each 60 ms.
Program B receives the message and prints the latency between the current message and the last message.

The result is the following:

latency 19
latency 60
latency 60
latency 60
latency 51
latency 59
latency 80
latency 61
latency 60
latency 58
latency 50
latency 60
latency 59
latency 538
latency 0
latency 43
latency 58
latency 62
latency 79
latency 50
latency 50
latency 61
latency 61
latency 58
latency 60
latency 80
latency 31
latency 59
latency 1946
latency 0
latency 54
latency 61
latency 49
latency 59
latency 52
latency 60
latency 58
latency 60
latency 60
latency 60
latency 60
latency 60
latency 51
latency 533
latency 0
latency 16
latency 60
latency 60
latency 60
latency 50
latency 60
latency 61
latency 60
latency 59

From time to time, in a pretty much regular way, the message receiving stalls and the latency is printed as being around 500ms/1000ms/2000ms.

Even the interval between stalls is pretty much regular, around 14 packets. Each packet is 76 bytes, which multiplied by 14 gives around 1024.

I didn’t rest while I couldn’t who the fault was. So I did a C program that receives data on a socket from the same source to ensure that there was no stalls or latency. The result was NO STALLS.

Then, I have done another program, this time built in Qt, to send data via QUdpSocket to the program B. The result was: STALLS again!

My conclusion is that somewhere in the underlying Qt socket handling, there is a buffer, to be filled before readyRead is sent. 

Is anybody familiar with this problem and know how to work around it? Is this a setting that can be tweaked? 

This doesn’t seem normal or acceptable. 

Thx,

Regards,

Nuno Santos


More information about the Interest mailing list