diff --git a/README.md b/README.md index 0d5cd15..f835e7c 100644 --- a/README.md +++ b/README.md @@ -10,3 +10,10 @@ Stateless `X <-> Y` formatting+conversion in Rust * [todo] kafka + a gui for live remapping STDIN to gamepad-ish buttons + +## StdIn to UDP + +``` +$ INPUT_NAME=stdin OUTPUT_NAME=udp OUTPUT_FORMAT="{{ ms_since_epoch }}|$USER|{{ VALUE }}" cargo run +$ INPUT_NAME=udp cargo run +``` diff --git a/src/stream.rs b/src/stream.rs index 8e1cd92..68f1110 100644 --- a/src/stream.rs +++ b/src/stream.rs @@ -116,6 +116,7 @@ pub struct InputStreamUDP { pub fn build_input_stream_udp(cfg: &Stream) -> Result { let udp_cfg = cfg.engine.udp.as_ref().unwrap(); + println!("$ echo -n 'hello world' | nc -4u -w0 localhost {}", &udp_cfg.port.to_string()); return Ok(InputStreamUDP{ last_socket: None, port: udp_cfg.port, @@ -125,7 +126,6 @@ pub fn build_input_stream_udp(cfg: &Stream) -> Result { impl InputStream for InputStreamUDP { fn get(&mut self) -> Vec { let addr = "0.0.0.0:".to_string() + &self.port.to_string(); - println!("$ echo -n 'hello world' | nc -4u -w0 localhost {}", &self.port.to_string()); if self.last_socket.is_none() { self.last_socket = Some(std::net::UdpSocket::bind(&addr).unwrap()); }