mirror of
https://github.com/maciejpedzich/f1-game-packet-parser.git
synced 2025-04-16 10:01:13 +02:00
misc: print UDP client listening message after successful socket bind
This commit is contained in:
parent
9fe4ec289d
commit
d2ded9da51
@ -3,13 +3,16 @@ use std::error::Error;
|
||||
use std::net::UdpSocket;
|
||||
|
||||
fn main() -> Result<(), Box<dyn Error>> {
|
||||
let socket = UdpSocket::bind("127.0.0.1:20777")?;
|
||||
let addr = "127.0.0.1:20777";
|
||||
let socket = UdpSocket::bind(addr)?;
|
||||
let mut buf = [0u8; 2048];
|
||||
|
||||
loop {
|
||||
let (msg_size, _) = socket.recv_from(&mut buf)?;
|
||||
let data = &buf[..msg_size];
|
||||
println!("UDP client is listening on {}", addr);
|
||||
|
||||
parse(data)?;
|
||||
loop {
|
||||
let (msg_len, _) = socket.recv_from(&mut buf)?;
|
||||
let msg = &buf[..msg_len];
|
||||
|
||||
parse(msg)?;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user