I'm using Mioco. mio::net::tcp::TcpStream
does not implement Clone
, so it seems that it's not possible to share a TcpStream
across multiple threads/coroutines (or if it is possible, I'm not sure how; I'm pretty new to Rust). I've hence assumed that for simultaneous reading/writing to a single TcpStream
, it's necessary to use a single coroutine to do both the reading and writing.
In order to avoid blocking indefinitely on reading when incoming data is infrequent, it seems like it would be necessary to use a timeout when reading from the TcpStream
. std::net::TcpStream
has set_read_timeout
for achieving this, but I can't find an equivalent for mio::net::tcp::TcpStream
. How would I go about this? Or is there a way to share the mio TcpStream
across multiple coroutines, avoiding the need for a timeout?