diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..304d52e --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,6 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "phetch" +version = "0.1.0" + diff --git a/src/main.rs b/src/main.rs index e7a11a9..78fa98a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,18 @@ +#![allow(unused_must_use)] + +use std::io::{Read, Write}; +use std::net::TcpStream; + fn main() { - println!("Hello, world!"); + TcpStream::connect("phkt.io:70") + .and_then(|mut stream| { + stream.write("\r\n".as_ref()).unwrap(); + let mut buf = String::new(); + stream.read_to_string(&mut buf); + println!("{}", buf); + Ok(()) + }) + .map_err(|err| { + eprintln!("err: {}", err); + }); }