gameServer2/src/main.rs
changeset 12137 193dfdcb0620
parent 12133 81df2e1f9ae9
child 12852 bd35cb2302b3
--- a/gameServer2/src/main.rs	Sat Jan 14 00:46:52 2017 +0300
+++ b/gameServer2/src/main.rs	Sat Jan 14 22:30:09 2017 +0300
@@ -4,6 +4,9 @@
 extern crate netbuf;
 #[macro_use]
 extern crate nom;
+#[macro_use]
+extern crate log;
+extern crate env_logger;
 
 //use std::io::*;
 //use rand::Rng;
@@ -16,7 +19,9 @@
 mod protocol;
 
 fn main() {
-    println!("Hedgewars game server, protocol {}", utils::PROTOCOL_VERSION);
+    env_logger::init().unwrap();
+
+    info!("Hedgewars game server, protocol {}", utils::PROTOCOL_VERSION);
 
     let address = "0.0.0.0:46631".parse().unwrap();
     let listener = TcpListener::bind(&address).unwrap();
@@ -43,6 +48,12 @@
                     tok => server.client_writable(&poll, tok).unwrap(),
                 }
             }
+            if event.kind().is_hup() || event.kind().is_error() {
+                match event.token() {
+                    utils::SERVER => unreachable!(),
+                    tok => server.client_error(&poll, tok).unwrap(),
+                }
+            }
         }
     }
 }