Created
July 31, 2022 11:21
-
-
Save gftea/f1de838ef016f8d876ba271eb350781b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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