-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Description
use wstd::io;
use wstd::iter::AsyncIterator;
use wstd::net::TcpListener;
#[wstd::main]
async fn main() -> io::Result<()> {
let listener = TcpListener::bind("127.0.0.1:8080").await?;
println!("Listening on {}", listener.local_addr()?);
println!("type `nc localhost 8080` to create a TCP client");
let mut incoming = listener.incoming();
while let Some(stream) = incoming.next().await {
let stream = stream?;
println!("Accepted from: {}", stream.peer_addr()?);
io::copy(&stream, &stream).await?;
}
Ok(())
}
Currently, the main example in this project is non-concurrent.
io::copy(&stream, &stream).await
blocks new incoming streams.
It doesn’t make much sense to use an async runtime if streams are processed sequentially.
It would be great to see this example become concurrent.
Related:
#17
yoshuawuyts/wasm-http-tools#7
Metadata
Metadata
Assignees
Labels
No labels