24 lines
477 B
Rust

use std::net::UdpSocket;
fn main() -> anyhow::Result<()> {
let input = UdpSocket::bind("0.0.0.0:54248")?;
loop {
let mut buf = [0u8; 4];
let Ok((amount, src)) = input.recv_from(&mut buf[..]) else {
continue;
};
if amount != 4 {
continue;
}
println!("Received packet: {}", i32::from_be_bytes(buf));
let Ok(_) = input.send_to(&buf, src) else {
continue;
};
}
}