Crates.io | ack-udp |
lib.rs | ack-udp |
version | 0.1.14 |
source | src |
created_at | 2023-05-02 11:35:25.368879 |
updated_at | 2023-05-06 12:58:08.318926 |
description | A bit more reliable UDP |
homepage | https://github.com/IDSaves/ack-udp |
repository | https://github.com/IDSaves/ack-udp |
max_upload_size | |
id | 854467 |
size | 23,597 |
[EXPERIMENTAL] A bit more reliable version of UDP written in Rust.
use std::{io, thread, time::Duration};
use ack_udp::AckUdp;
#[tokio::main]
fn main() -> io::Result<()> {
// Creating sender and receiver sockets
let mut sender = AckUdp::new("127.0.0.1:9023".parse().unwrap()).await?;
let mut receiver = AckUdp::new("127.0.0.1:9024".parse().unwrap()).await?;
let message = String::from("test").as_bytes().to_vec();
let status = sender.send(&message, "127.0.0.1:9024".parse().unwrap())?;
println!("{:?}", status); // Printing the status of the send
thread::sleep(Duration::from_millis(5)); // Simulating the wait time
// Receiving data
let (_, datagram) = receiver.recv().unwrap();
println!("{:?}, {:?}", datagram, status);
Ok(())
}