Begining of the machine oracle (work in progress..)
[crypto_lab1.git] / src / end_point.rs
index b44afc9..2d0a66c 100644 (file)
@@ -15,7 +15,7 @@ pub struct Client {
    end_point: EndPoint,
 }
 
-struct EndPoint {
+pub struct EndPoint {
    socket: TcpStream,
    current_timestamp: u64
 }
@@ -32,10 +32,10 @@ impl Server {
          loop {
             for stream in acceptor.incoming() {
                match stream {
-                  Err(_) => return,
                   Ok(stream) => spawn(proc() {
-                     Server::handle_client(EndPoint { socket: stream, current_timestamp: 0 });
-                  })
+                     Server::handle_client(EndPoint::new(stream));
+                  }),
+                  _ => return
                }
             }
          }
@@ -246,6 +246,10 @@ impl Client {
 }
 
 impl EndPoint {
+   pub fn new(socket: TcpStream) -> EndPoint {
+      EndPoint { socket: socket, current_timestamp: 0 }
+   }
+
    fn close(&mut self) -> IoResult<()> {
       try!(self.socket.close_read());
       try!(self.socket.close_write());