Skip to content

Instantly share code, notes, and snippets.

@benaryorg
Last active August 4, 2018 13:28
Show Gist options
  • Save benaryorg/87c3024b7e4f107ece10744e79fdfbaa to your computer and use it in GitHub Desktop.
Save benaryorg/87c3024b7e4f107ece10744e79fdfbaa to your computer and use it in GitHub Desktop.
use std::io::BufRead;
use std::io::BufReader;
use std::io::Write;
use std::net::Ipv4Addr;
use std::net::TcpListener;
use std::net::TcpStream;
fn main() -> std::io::Result<()>
{
let listen = try!(TcpListener::bind(("::",1337)));
let mut client = try!(TcpStream::connect((Ipv4Addr::new(127,0,0,1),1337)));
let (server,_) = try!(listen.accept());
let reader = BufReader::new(server);
let _ = try!(client.write(b"Meow.\n"));
let line = try!(reader.lines().next().expect("nothing received"));
println!("{}",line);
Ok(())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment