Skip to content

How I shutdown WriteHalf outside #3394

Answered by Darksonn
windniw asked this question in Q&A
Discussion options

You must be logged in to vote

How about this?

let (mut ri, mut wi) = inbound.split();
let (mut ro, mut wo) = outbound.split();

// This runs both until _one_ of them returns.
tokio::select! {
    res = io::copy(&mut ri, &mut wo) => res?,
    res = io::copy(&mut ro, &mut wi) => res?,
}

wi.shutdown().await?;
wo.shutdown().await?;

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@windniw
Comment options

@ririsoft
Comment options

@Darksonn
Comment options

@ririsoft
Comment options

Answer selected by windniw
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants