equal
deleted
inserted
replaced
1 extern crate rand; |
1 extern crate rand; |
2 extern crate mio; |
2 extern crate mio; |
3 extern crate slab; |
3 extern crate slab; |
|
4 extern crate netbuf; |
4 |
5 |
5 //use std::io::*; |
6 //use std::io::*; |
6 //use rand::Rng; |
7 //use rand::Rng; |
7 //use std::cmp::Ordering; |
8 //use std::cmp::Ordering; |
8 use mio::tcp::*; |
9 use mio::tcp::*; |
25 |
26 |
26 loop { |
27 loop { |
27 poll.poll(&mut events, None).unwrap(); |
28 poll.poll(&mut events, None).unwrap(); |
28 |
29 |
29 for event in events.iter() { |
30 for event in events.iter() { |
30 match event.token() { |
31 if event.kind().is_readable() { |
31 utils::SERVER => server.accept(&poll).unwrap(), |
32 match event.token() { |
32 _ => unreachable!(), |
33 utils::SERVER => server.accept(&poll).unwrap(), |
|
34 tok => server.client_readable(&poll, tok).unwrap(), |
|
35 } |
|
36 } |
|
37 if event.kind().is_writable() { |
|
38 match event.token() { |
|
39 utils::SERVER => unreachable!(), |
|
40 tok => server.client_writable(&poll, tok).unwrap(), |
|
41 } |
33 } |
42 } |
34 } |
43 } |
35 } |
44 } |
36 } |
45 } |