initial; first section

This commit is contained in:
2019-01-22 19:53:57 +01:00
commit f083abaf6d
9 changed files with 1405 additions and 0 deletions

24
hello-world/src/main.rs Normal file
View File

@@ -0,0 +1,24 @@
extern crate tokio;
use tokio::io;
use tokio::net::TcpStream;
use tokio::prelude::*;
fn main() {
let addr = "127.0.0.1:6142".parse().unwrap();
let client = TcpStream::connect(&addr).and_then(|stream| {
println!("created stream");
io::write_all(stream, "hello world\n").then(|result| {
println!("wrote to stream; success={:?}", result.is_ok());
Ok(())
})
})
.map_err(|err| {
println!("connection error = {:?}", err);
});
println!("About to create the stream and write to it...");
tokio::run(client);
println!("Stream has been created and written to.");
}