An opiniated UDP listener and publisher
There are many options on configuring your UDP client and server
Toml
[[bind_addresses]]
ip = "127.0.0.1"
port = 5061
[destination_address]
ip = "127.0.0.1"
port = 5060
rust
let config = Config::from_arguments(
vec![(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 5061)],
Some((IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 5060)),
);
bash
export BIND_ADDRS=127.0.0.1
export BIND_PORT=5061
export DEST_ADDRS=127.0.0.1
export DEST_PORT=5060
rust
let config = Config::from_env();
rust
polygon.send("Hello World".to_string());
``` rust let rx = polygon.receive();
loop {
let maybe = rx.try_recv();
if let Ok(data) = maybe {
println!("receiving... {data:?}");
}
}
```
Retransmits a message with specific delays
``` rust polygon.sendwithtimer( "Hello World".to_string(), Timers { delays: vec![500, 600, 1000, 1500], }, );
```
retransmissions can be paused at any given time, even mid sending a message, effectively cancelling a retransmission
rust
let mut polygon = Polygon::configure(config);
let pause = Arc::clone(&polygon.pause_timer_send);
*pause.lock().unwrap() = true;
or
rust
let mut polygon = Polygon::configure(config);
polygon.pause_timer_send()
polygon.resume_timer_send()
this will make the sendwithtimer to behave like a normal send (only it would still require tokio)