From bae2586623a4f966d3fde9b8148a5ad2faccb1bb Mon Sep 17 00:00:00 2001 From: ingressy Date: Tue, 17 Mar 2026 19:41:14 +0000 Subject: [PATCH] =?UTF-8?q?src/test.rs=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/test.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/test.rs diff --git a/src/test.rs b/src/test.rs new file mode 100644 index 0000000..a102212 --- /dev/null +++ b/src/test.rs @@ -0,0 +1,16 @@ +use std::net::UdpSocket; + +//call from main fn +pub fn sendtestudp(to: String, port: u16, payload: String) { + let socket = UdpSocket::bind("0.0.0.0:0").expect("couldn't bind to address"); + let to = format!("{}:{}", to, port); + + //form hex string to real hex -> FF == 0xFF + let bytes: Vec = (0..payload.len()) + .step_by(2) + .map(|i| u8::from_str_radix(&payload[i..i+2], 16).expect("not a real hex")) + .collect(); + + socket.send_to(&bytes, to); + +} \ No newline at end of file