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