X-Git-Url: http://git.euphorik.ch/?a=blobdiff_plain;f=lab1_rust%2Fsrc%2Fend_point.rs;h=bf8d4de8a7ecaa3b63d36ca1ce4f59f6edc1251c;hb=e389f9aabe1585c2e5111e4bf874e7dbc29935b3;hp=51b55b8d284a0bde9d00545d63b1a5bb68327e26;hpb=d3d8743586e533af4f32c1edfcff6377161d7cf4;p=crypto_lab1.git diff --git a/lab1_rust/src/end_point.rs b/lab1_rust/src/end_point.rs index 51b55b8..bf8d4de 100644 --- a/lab1_rust/src/end_point.rs +++ b/lab1_rust/src/end_point.rs @@ -23,7 +23,7 @@ pub struct EndPoint { impl Server { pub fn new(interface: &str, port: u16, variant: packet::Variant) -> IoResult { - let mut acceptor = try!(TcpListener::bind(interface, port).listen()); + let mut acceptor = try!(TcpListener::bind((interface, port)).listen()); let server = Server { acceptor: acceptor.clone() @@ -77,7 +77,7 @@ impl Server { impl Client { pub fn new(address: &str, port: u16, variant: packet::Variant) -> IoResult { Ok(Client { end_point: EndPoint { - socket: try!(TcpStream::connect(address, port)), + socket: try!(TcpStream::connect((address, port))), current_timestamp: 0, variant: variant, }}) @@ -118,7 +118,7 @@ impl Client { } } - /// Send some valid and not-valid packets to the server and check the result. + /// Sends some valid and not-valid packets to the server and check the result. /// For each test a new client is created. pub fn start_tests(address: &str, port: u16, variant: packet::Variant) { let execute = |f: &mut |&mut Client| -> bool| -> bool { @@ -269,7 +269,7 @@ impl EndPoint { println!("[{}] time: {}. {}", prefix, self.current_timestamp, s); } - /// Send a packet and wait for an answer synchronously. + /// Sends a packet and wait for an answer synchronously. fn send_with_result(&mut self, p: PacketType) -> IoResult { match self.send(p) { Err(e) => Err(e), @@ -277,8 +277,8 @@ impl EndPoint { } } - /// Send arbitrary data and wait for an answer synchronously. - /// Do not increment the current timestamp. + /// Sends arbitrary data and wait for an answer synchronously. + /// Doesn't increment the current timestamp. pub fn send_raw_with_result(&mut self, p: &[u8]) -> IoResult { self.socket.set_timeout(DEFAULT_TIMEOUT); match self.socket.write(p) {