|
|
@@ -1,23 +1,31 @@ |
|
|
|
use std::io::Write; |
|
|
|
use std::net::TcpStream; |
|
|
|
|
|
|
|
fn main() { |
|
|
|
let stream = TcpStream::connect("127.0.0.1:8080"); |
|
|
|
if stream.is_ok() { |
|
|
|
println!("Connected to the server!"); |
|
|
|
} else { |
|
|
|
println!("Couldn't connect to server..."); |
|
|
|
} |
|
|
|
//let stream = TcpStream::connect("172.30.16.1:8080"); |
|
|
|
//let stream = TcpStream::connect("27.0.0.1:8080"); |
|
|
|
match TcpStream::connect("localhost:3333") { |
|
|
|
Ok(mut stream) => { |
|
|
|
println!("Successfully connected to server"); |
|
|
|
|
|
|
|
loop { |
|
|
|
let mut buffer = String::new(); |
|
|
|
match std::io::stdin().read_line(&mut buffer){ |
|
|
|
Ok(_n) => { |
|
|
|
println!("{}", buffer); |
|
|
|
} |
|
|
|
Err(_error) =>{ |
|
|
|
println!("Fehlerhafte Eingabe!"); |
|
|
|
break; |
|
|
|
loop { |
|
|
|
let mut buffer = String::new(); |
|
|
|
match std::io::stdin().read_line(&mut buffer){ |
|
|
|
Ok(_n) => { |
|
|
|
println!("Sending {}", buffer); |
|
|
|
stream.write(buffer.as_bytes()).unwrap(); |
|
|
|
println!("Sent {}, awaiting reply...", buffer); |
|
|
|
} |
|
|
|
Err(_error) =>{ |
|
|
|
println!("Fehlerhafte Eingabe!"); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
Err(e) => { |
|
|
|
println!("Failed to connect: {}", e); |
|
|
|
} |
|
|
|
} |
|
|
|
println!("Terminated."); |
|
|
|
} // the stream is closed here |