Skip to content

Instantly share code, notes, and snippets.

@kariya-mitsuru
Created December 14, 2018 00:18
Show Gist options
  • Save kariya-mitsuru/cac00e080f4416a4cce6731f6f8784bf to your computer and use it in GitHub Desktop.
Save kariya-mitsuru/cac00e080f4416a4cce6731f6f8784bf to your computer and use it in GitHub Desktop.
TcpListener Test
use std::net::TcpListener;
use std::io::Write;
fn main() {
let listener = TcpListener::bind("127.0.0.1:8080").unwrap();
for stream in listener.incoming() {
match stream {
Ok(mut stream) => {
let _ = stream.write(b"test\n");
}
Err(_) => {
panic!("connection failed")
}
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment