send input from client
This commit is contained in:
parent
598245457e
commit
3691679be4
@ -1,23 +1,31 @@
|
|||||||
|
use std::io::Write;
|
||||||
use std::net::TcpStream;
|
use std::net::TcpStream;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let stream = TcpStream::connect("127.0.0.1:8080");
|
//let stream = TcpStream::connect("172.30.16.1:8080");
|
||||||
if stream.is_ok() {
|
//let stream = TcpStream::connect("27.0.0.1:8080");
|
||||||
println!("Connected to the server!");
|
match TcpStream::connect("localhost:3333") {
|
||||||
} else {
|
Ok(mut stream) => {
|
||||||
println!("Couldn't connect to server...");
|
println!("Successfully connected to server");
|
||||||
}
|
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
let mut buffer = String::new();
|
let mut buffer = String::new();
|
||||||
match std::io::stdin().read_line(&mut buffer){
|
match std::io::stdin().read_line(&mut buffer){
|
||||||
Ok(_n) => {
|
Ok(_n) => {
|
||||||
println!("{}", buffer);
|
println!("Sending {}", buffer);
|
||||||
}
|
stream.write(buffer.as_bytes()).unwrap();
|
||||||
Err(_error) =>{
|
println!("Sent {}, awaiting reply...", buffer);
|
||||||
println!("Fehlerhafte Eingabe!");
|
}
|
||||||
break;
|
Err(_error) =>{
|
||||||
|
println!("Fehlerhafte Eingabe!");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
Err(e) => {
|
||||||
|
println!("Failed to connect: {}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
println!("Terminated.");
|
||||||
} // the stream is closed here
|
} // the stream is closed here
|
Loading…
x
Reference in New Issue
Block a user