diff --git a/src/client.rs b/src/client.rs index 1250b69..911a4ec 100644 --- a/src/client.rs +++ b/src/client.rs @@ -47,13 +47,15 @@ pub async fn client_mode(client_config: ClientConfiguration, fd: i32, env: &JNIE let lltx = ltx.clone(); tokio::spawn(async move { - while let Ok(bytes) = rx.recv() { - lltx.send("Write to tun.".as_bytes().to_vec()); - if let Err(e) = dev_writer.write_all(&bytes).await { - lltx.send(format!("Writing error: {:?}", e).as_bytes().to_vec()); - } - if let Err(e) = dev_writer.flush().await { - lltx.send(format!("Flushing error: {:?}", e).as_bytes().to_vec()); + loop { + if let Ok(bytes) = rx.recv() { + lltx.send("Write to tun.".as_bytes().to_vec()); + if let Err(e) = dev_writer.write_all(&bytes).await { + lltx.send(format!("Writing error: {:?}", e).as_bytes().to_vec()); + } + if let Err(e) = dev_writer.flush().await { + lltx.send(format!("Flushing error: {:?}", e).as_bytes().to_vec()); + } } } });