Steps to recreate the issue:
-
Create a 20MB file to download named
file.txt
truncate -s 20MB file.txt
-
Run the TCP server:
cargo run --release --bin tcp_server
-
Run the TCP client
cargo run --release --bin tcp_client
The error will present itself when tokio::io::read
will return 0, even if all the
file data has been sent from the TCP server, for example as:
thread 'tokio-runtime-worker-4' panicked at 'Received less than expected: 19991908 bytes Take { inner: TcpStream { addr: V4(127.0.0.1:38606), peer: V4(127.0.0.1:49152), fd: 186 }, limit: 8092 }', src/tcp_client.rs:46:17