mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-12-28 06:38:20 -06:00
15 lines
321 B
Rust
15 lines
321 B
Rust
|
use std::net::{UdpSocket, SocketAddr};
|
||
|
use crate::BINCODE_CONFIG;
|
||
|
|
||
|
pub struct Server {
|
||
|
socket: UdpSocket,
|
||
|
}
|
||
|
impl Server {
|
||
|
pub fn bind(addr: SocketAddr) -> anyhow::Result<Self> {
|
||
|
let socket = UdpSocket::bind(addr)?;
|
||
|
socket.set_nonblocking(true)?;
|
||
|
socket.set_broadcast(true)?;
|
||
|
Ok(Self { socket })
|
||
|
}
|
||
|
}
|