I used this code for the server, and modified this tutorial for the client code. When a client connects to the server, it blocks itself forever.
Server:
The problem has nothing to do with futures. You have an open socket and you ask to "read it until the end". What determines the end? In this case, it's when the socket is closed; so when is that?
Trick question!
So when does that happen? Because there's no code that does it specifically, it will close when the socket is dropped, so:
Thus the deadlock. The issue can be fixed by explicitly closing the write half of the socket:
let response = request.and_then(|(socket, _)| {
socket.shutdown(std::net::Shutdown::Write).expect("Couldn't shut down");
read_to_end(socket, Vec::new())
});