I am experimenting with mio to build a high performance tcp server. I started from the example here https://github.com/tokio-rs/mio/blob/master/examples/tcp_server.rs and hit it with hyperfine running this code as a sort of benchmark / feeling the server out.
fn main() {
let mut stream = TcpStream::connect("127.0.0.1:9000").expect("Failed to connect to server.");
stream.write("some_data".as_bytes()).unwrap();
}
This always errors out with the follwing
Error: Os { code: 54, kind: ConnectionReset, message: "Connection reset by peer" }
Thrown from line 156 in the example.
I understand this is the expected behaviour if this error is thrown what I am trying to understand what would cause the TcpStream to throw this error in the first place. I feel this example should handle quite a lot of load.
Also if this is maybe not the best place to start building with Mio I'd appreciate any pointers as to where to look.