# service.rs — UDP Socket

`<span class="editor-theme-code">UdpService</span>`<span style="white-space: pre-wrap;"> is a thin wrapper that binds a UDP socket and holds it in an </span>`<span class="editor-theme-code">Arc<UdpSocket></span>`<span style="white-space: pre-wrap;"> so it can be shared across async tasks. It is registered as Tauri managed state at startup so any command can access the socket via </span>`<span class="editor-theme-code">State<'_, UdpService></span>`.

- Binds to address passed from lib.rs — listens on all interfaces on the chosen port
- `<span class="editor-theme-code">socket()</span>`<span style="white-space: pre-wrap;"> returns a cloned </span>`<span class="editor-theme-code">Arc</span>`<span style="white-space: pre-wrap;"> to the socket for use in other tasks</span>

<p class="callout info">`<span class="editor-theme-code">socket2</span>`<span style="white-space: pre-wrap;"> allows to customize the socket, otherwise the buffer size will be set by the system and be too small</span></p>