From c96a0116c7de390ab0e3f79b0deaeea808fee29f Mon Sep 17 00:00:00 2001 From: mattbk Date: Sat, 27 Sep 2025 10:03:59 -0500 Subject: [PATCH] Send simple UDP stuff. --- src/main.rs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index e2d4a12..279d0cb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,7 @@ use clap::{Parser, ArgGroup}; use std::io::{self, Read, Write}; use std::net::{IpAddr, TcpStream}; +use std::net::UdpSocket; /// Validate IP address. fn validate_ip(ip: &str) -> Result { @@ -108,8 +109,21 @@ fn main() -> Result<(), Box> { }; // Send the frame. - send_frame(&frame, &cli.ip.to_string(), cli.port)?; + //send_frame(&frame, &cli.ip.to_string(), cli.port)?; + //Ok(()) + + // Bind a UDP socket to an address; here, "0.0.0.0:0" finds a free port automatically + let socket = UdpSocket::bind("0.0.0.0:0")?; + + // Define the target address and port + let target_address = "report.pskreporter.info:14739"; + + // Send the message + socket.send_to(&frame, target_address)?; + println!("Message sent successfully."); Ok(()) + + } /// Build 'M' frame (unproto without digipeaters). @@ -174,4 +188,5 @@ fn send_frame(frame: &[u8], host: &str, port: u16) -> io::Result<()> { let mut stream = TcpStream::connect(addr)?; stream.write_all(frame)?; Ok(()) -} \ No newline at end of file +} +