3

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();
Nick
  • 10,309
  • 21
  • 97
  • 201

1 Answers1

2

From cargo doc

To restore this read/write object from its split::ReadHalf and split::WriteHalf use unsplit.
Asya Corbeau
  • 209
  • 1
  • 4
  • At least in current versions, [`tokio::net::tcp::ReadHalf`](https://docs.rs/tokio/1.24.1/tokio/net/tcp/struct.ReadHalf.html) does not have an `unsplit` method. – talz Jan 10 '23 at 21:42