Created
December 25, 2018 11:23
-
-
Save yoshuawuyts/f10ed1bbaa9d1cb0ca12061c1fcf4a0f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() -> io::Result<()> { | |
executor::block_on(async { | |
let listener = TcpListener::bind(&"127.0.0.1:7878".parse().unwrap())?; | |
let mut incoming = listener.incoming(); | |
while let Some(stream) = await!(incoming.next()) { | |
let stream = stream?; | |
let addr = stream.peer_addr()?; | |
juliex::spawn(async move { | |
let (mut reader, mut writer) = stream.split(); | |
await!(reader.copy_into(&mut writer)).unwrap(); // Just unwrap? | |
}); | |
} | |
Ok(()) | |
}) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async fn main() -> io::Result<()> { | |
let listener = TcpListener::bind(&"127.0.0.1:7878".parse()?)?; | |
#[parallel] | |
for await stream? in listener.incoming() { | |
let (mut reader, mut writer) = stream.split(); | |
await reader.copy_into(&mut writer)?; | |
} | |
Ok(()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment