Fix: configure and read from socket correctly in 08/05

This commit is contained in:
LukeMathWalker
2024-05-16 10:14:46 +02:00
parent 804b275b06
commit 5d68add5ad
2 changed files with 6 additions and 5 deletions

View File

@@ -9,8 +9,9 @@ pub async fn echo(listener: TcpListener) -> Result<(), anyhow::Error> {
loop {
let (socket, _) = listener.accept().await?;
let mut socket = socket.into_std()?;
socket.set_nonblocking(false)?;
let mut buffer = Vec::new();
while let Ok(_) = socket.read(&mut buffer) {}
socket.read_to_end(&mut buffer)?;
socket.write_all(&buffer)?;
}
}