summaryrefslogtreecommitdiff
path: root/src/bin/server.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/server.rs')
-rw-r--r--src/bin/server.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/bin/server.rs b/src/bin/server.rs
new file mode 100644
index 0000000..71541f8
--- /dev/null
+++ b/src/bin/server.rs
@@ -0,0 +1,24 @@
+use std::io::prelude::*;
+use std::net::{TcpListener, TcpStream};
+
+extern crate space;
+use space::connection::Connection;
+
+fn main() {
+ let listener = TcpListener::bind("localhost:6000").unwrap();
+ listener.set_nonblocking(true);
+
+ let mut connections = Vec::new();
+ loop {
+ for stream in listener.incoming() {
+ match stream {
+ Ok(stream) => connections.push(Connection::new(stream)),
+ _ => (),
+ }
+ for i in 0..connections.len() {
+ connections[i].process();
+ }
+ connections.retain(|connection| connection.open );
+ }
+ }
+}