UDP receive and send with julia

I have an application which reads UDP data, processes it and displays it. I don’t know if that’s similar to your case, but if it is then the following might be useful:

  • I separated the udp receive, processing and display into separate tasks running on different threads using ThreadPools.@tspawnat. For some reason Threads.@spawn assigns tasks to random threads and they can end up all running on the same one.

  • I used Channel() for a blocking, thread-safe queue to communicate between tasks. This allows the receive to carry on if, e.g. the processing operates on larger blocks and could cause packets to be dropped.

  • I found I had to increase the UDP buffer size as the default kept dropping packets. You may not have to do that depending on data rate, etc. - mine runs on a Windows laptop and receives around 65 Mbps. I don’t think UDPSocket() allows you to change the buffer size directly but there’s a dicussion on how to do it at Set UDPSocket reciever buffer size? - #4 by ufechner7