diff --git a/src/worker.rs b/src/worker.rs index 3e39e83..bd5c61d 100644 --- a/src/worker.rs +++ b/src/worker.rs @@ -9,6 +9,7 @@ use std::{ const MAX_RETRIES: u32 = 6; const TIMEOUT_BUFFER: Duration = Duration::from_secs(1); +const DEFAULT_DUPLICATE_DELAY: Duration = Duration::from_millis(1); /// Worker `struct` is used for multithreaded file sending and receiving. /// It creates a new socket using the Server's IP and a random port @@ -241,7 +242,10 @@ impl Worker { } fn send_packet(&self, packet: &Packet) -> Result<(), Box> { - for _ in 0..self.duplicate_packets { + for i in 0..self.duplicate_packets { + if i > 0 { + std::thread::sleep(DEFAULT_DUPLICATE_DELAY); + } self.socket.send(packet)?; }