Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to rejoin `ReadHalf` and `WriteHalf` into a `TcpStream`

Is there a way to rejoin a Tokio ReadHalf and WriteHalf into a TcpStream after a split?

let mut stream = TcpStream::connect("127.0.0.1:8080").await?;
let (reader, writer) = stream.split();

// re-join pseudo-code
let stream: TcpStream = (reader, writer).join();
like image 840
Nick Avatar asked Dec 05 '25 19:12

Nick


1 Answers

From cargo doc

To restore this read/write object from its split::ReadHalf and split::WriteHalf use unsplit.
like image 183
Asya Corbeau Avatar answered Dec 08 '25 23:12

Asya Corbeau



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!