diff options
| author | tom barrett <spalf0@gmail.com> | 2018-02-21 06:27:02 -0600 | 
|---|---|---|
| committer | tom barrett <spalf0@gmail.com> | 2018-02-21 06:27:02 -0600 | 
| commit | d42a28c46057c386d161bfe438302e2314f0a6f6 (patch) | |
| tree | 9802462761e4e41bc4419b700e4a42b06919f5b5 /src/bin/server.rs | |
| parent | 6fb01a0cb228b1aa08e47e8dbcd6b46c43bde06b (diff) | |
-got engine and dashboard data sending
Diffstat (limited to 'src/bin/server.rs')
| -rw-r--r-- | src/bin/server.rs | 27 | 
1 files changed, 15 insertions, 12 deletions
| diff --git a/src/bin/server.rs b/src/bin/server.rs index 71541f8..871315e 100644 --- a/src/bin/server.rs +++ b/src/bin/server.rs @@ -1,24 +1,27 @@ -use std::io::prelude::*; -use std::net::{TcpListener, TcpStream}; +use std::thread::sleep; +use std::time::Duration; +use std::net::TcpListener;  extern crate space;  use space::connection::Connection;  fn main() {      let listener = TcpListener::bind("localhost:6000").unwrap(); -    listener.set_nonblocking(true); +    listener.set_nonblocking(true).unwrap();      let mut connections = Vec::new(); -    loop { -        for stream in listener.incoming() { -            match stream { -                Ok(stream) => connections.push(Connection::new(stream)), -                _ => (), +    for stream in listener.incoming() { +        match stream { +            Ok(stream) => connections.push(Connection::new(stream)), +            _ => { +                println!("looped"); +                for i in 0..connections.len() { +                    connections[i].process(); +                } +                connections.retain(|connection| connection.open ); +                sleep(Duration::from_millis(100));              } -            for i in 0..connections.len() { -                connections[i].process(); -            } -            connections.retain(|connection| connection.open );          }      } +  } | 
