I was implementing a TCP based protocol to communicate with a DALI converter.
When banging the output I noticed that only some messages would go through and return the acknowledgement message.
Turns out that the way the current TCPClient is patched it’s quite prone to miss data.
This is due to the fact that the AsyncLoop is never in sync with the main loop and therefore it may miss data available only for one mainloop frame - it’s not very thread safe.
I’ve repatched it to queue up the data using a concurrent queue.
The queue is then passed to the AsyncLoop which then sends out a batch of the data in a single iteration.
The size of the queue is limited. If you keep adding data to be sent that goes over the limit, the new packets will be preferred over the old ones.
From my testing it’s considerably more reliable than the previous version. Something that you would expect from TCP.
It would be nice if it could replace the current TCPClient in VL, hopefully bringing it closer to non-experimental.
Further discussion and improvement suggestions are of course welcome.
Here’s the Queued TCPClient version.
TCPClient.Queued.vl (38.2 KB)