# UDP receive and send with julia

**URL:** https://discourse.julialang.org/t/udp-receive-and-send-with-julia/62349
**Category:** New to Julia
**Created:** [June 3, 2021, 7:03pm UTC](https://discourse.julialang.org/t/udp-receive-and-send-with-julia/62349 "2021-06-03T19:03:53Z")
**Posts on this page:** 1
**Showing post:** 3

<div class="post-metadata">

### Author: ![tt1234567](https://avatars.discourse-cdn.com/v4/letter/t/dec6dc/32.png) [@tt1234567](https://discourse.julialang.org/u/tt1234567)
#### Post date: [June 4, 2021, 1:52pm UTC](https://discourse.julialang.org/t/udp-receive-and-send-with-julia/62349/3 "2021-06-04T13:52:11Z")

</div>

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](https://discourse.julialang.org/t/set-udpsocket-reciever-buffer-size/3939/4)

---

_[View the full topic](https://discourse.julialang.org/t/udp-receive-and-send-with-julia/62349)._
