+ let socket = UdpSocket::bind("0.0.0.0:29803").expect("couldn't bind to address");
+ loop {
+ let mut buf = [0; MESSAGE_SIZE];
+ match socket.recv_from(&mut buf) {
+ Err(e) => eprintln!("Didn't receive data: {e}"),
+ Ok((number_of_bytes, src_addr)) => {
+ let filled_buf = &mut buf[..number_of_bytes];
+ if number_of_bytes != MESSAGE_SIZE {
+ eprintln!("Ignoring short message ({number_of_bytes}) from {src_addr}");
+ continue;
+ }
+ println!("Got packet from {src_addr}: {filled_buf:?}");
+ }
+ }
+ }