Skip to content

Instantly share code, notes, and snippets.

@gftea
Created July 31, 2022 11:21
Show Gist options
  • Save gftea/f1de838ef016f8d876ba271eb350781b to your computer and use it in GitHub Desktop.
Save gftea/f1de838ef016f8d876ba271eb350781b to your computer and use it in GitHub Desktop.
use async_runtime::Runtime;
use async_runtime::net::AsyncTcpStream;
fn main() {
let rt = Runtime;
rt.run(async {
println!("top future start");
let mut stream = AsyncTcpStream::connect("127.0.0.1:8080");
let mut buf = vec![0;100];
let n = stream.read(&mut buf).await;
println!("{:?}", String::from_utf8(buf[0..n].into()));
stream.close();
println!("top future end");
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment