07-31-2020 01:36 PM
I have a program in LabVIEW that when started opens a UDP socket using the UDP Open function, then passes the reference into a while loop that repeats every 50ms. Inside this while loop I read datagrams using the UDP Read function. When the application is closed it will close the UDP socket using the UDP Closed function.
The UDP messages are generated by a seperate program that was set to send data every 20ms. I noticed that this would cause a delay as it seems that the datagrams are being queued and when the UDP Read message is executed it will dequeue the datagrams one at a time first come first serve.
I was curious if there is a way to tell the UDP Read function to ignore any past datagrams and only return the latest one, assuming at least one exists.
Thank you
07-31-2020 01:50 PM
07-31-2020 02:11 PM
Thank you, it is part of some legacy code from years ago so I can't speak to why they wanted a hard coded 50ms wait. There timeout of the read message is 0 so my guess is they just wanted to get data at a constant rate to keep the UDP reading from bogging down the rest of the system. As far as use it is less important that we recieve every piece of data that comes across than it is for our data to be current with what was most recently being sent.