Skip to main content

service.rs — UDP Socket

UdpService is a thin wrapper that binds a UDP socket and holds it in an Arc<UdpSocket> 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 State<'_, UdpService>.

  • Binds to address passed from lib.rs — listens on all interfaces on the chosen port
  • socket() returns a cloned Arc to the socket for use in other tasks

socket2 allows to customize the socket, otherwise the buffer size will be set by the system and be too small