I have a client/server setup with QTcpSocket and QTcpServer, it's a real-time thing so it needs to be as fast as possible ideally, but packets are only being sent and received every ~0.5 seconds even though they are really small (rarely more than a few bytes). also it's really important that no packets are lost so I can't use UDP. I saw another thread where someone said to set QAbstractSocket::LowDelayOption to 1 for each client, on the server side, but I tried that and it made no difference. Is there any way to make it faster?
Asked
Active
Viewed 515 times
0
-
1If you are sending time-sensitive data from the client to server, you'll probably want to set the LowDelayOption on the client side also. – Jeremy Friesner Aug 12 '14 at 04:48
-
Just tried that and it still didn't seem to make a difference... – Ben Aug 12 '14 at 15:19
1 Answers
0
TCP sockets try to fit as much data as possible in each datagram, so 0.5s is probably the time the operating system decides it has waited enough time and no more data is going to be sent for now, and it decides to flush the socket send buffer to the network.
You can try using flush() to force a push of the buffered data to the network.

Juliano
- 39,173
- 13
- 67
- 73
-
`flush()` doesn't force things onto the network, only to the *network stack*. The data is presented to the operating system, that's it. Using the `LowDelayOption` is the only workaround for the TCP socket, and this is *not Qt specific at all*. – Kuba hasn't forgotten Monica Aug 12 '14 at 07:09