Last active
July 24, 2017 19:27
-
-
Save sproctor/8f6271287d3fb410015fb9f6e7e75715 to your computer and use it in GitHub Desktop.
colony working draft
This file contains 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 std::io::Write; | |
use std::net::TcpListener; | |
use std::net::TcpStream; | |
use std::thread; | |
fn main() { | |
println!("Creating server"); | |
// let ip = Ipv4Addr::new(127, 0, 0, 1); | |
let port = 9000; | |
let host = "127.0.0.1"; | |
let listener = TcpListener::bind((host, port)).unwrap(); | |
println!("Listener bound, ready to accept connections"); | |
for stream in listener.incoming() { | |
thread::spawn(|| { handle_client(stream.unwrap()); }); | |
} | |
} | |
fn handle_client(mut stream : TcpStream) { | |
let _ = stream.write(b"Welcome to Colony!\r\n"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment