some basic code

This commit is contained in:
2025-07-25 13:16:38 +02:00
parent 89152e24b3
commit 3e736aaf45
6 changed files with 566 additions and 6 deletions
+16 -2
View File
@@ -1,3 +1,17 @@
fn main() {
println!("Hello, world!");
use std::net::UdpSocket;
fn main() -> std::io::Result<()> {
{
let socket: UdpSocket = (|| -> std::io::Result<UdpSocket> {
let mut port: u16 = 59999;
loop {
port += 1;
match UdpSocket::bind(format!("0.0.0.0:{}", port)) {
Ok(socket) => return Ok(socket),
Err(_) => continue, // Retry on error
}
}
})()
.expect("Failed to bind to any available port");
}
Ok(())
}