Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fn main() {
- let listener = TcpListener::bind("127.0.0.1", 80);
- // bind the listener to the specified address
- let mut acceptor = listener.listen(); //unwrap() here
- fn handle_client(mut stream: TcpStream) {
- println!("a");
- }
- // accept connections and process them, spawning a new tasks for each one
- for stream in acceptor.incoming() {
- match stream {
- Err(e) => { /* connection failed */ }
- Ok(stream) =>
- spawn(proc() {
- // connection succeeded
- handle_client(stream)
- })
- }
- }
- // close the socket server
- drop(acceptor);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement