Compare commits

..

No commits in common. "ed06a50aa8eaa503ad339743497481bc187e23fe" and "829db5445ed2eb44e85814f972c3c7168bffc64a" have entirely different histories.

View File

@ -1,12 +1,12 @@
use std::io::Write;
use std::net::TcpStream; use std::net::TcpStream;
fn main() { fn main() {
//let stream = TcpStream::connect("172.30.16.1:8080"); let stream = TcpStream::connect("127.0.0.1:8080");
//let stream = TcpStream::connect("27.0.0.1:8080"); if stream.is_ok() {
match TcpStream::connect("localhost:3333") { println!("Connected to the server!");
Ok(mut stream) => { } else {
println!("Successfully connected to server"); println!("Couldn't connect to server...");
}
loop { loop {
let mut buffer = String::new(); let mut buffer = String::new();
@ -15,9 +15,7 @@ fn main() {
if n == 0 { if n == 0 {
break; break;
} }
println!("Sending {}", buffer); println!("{}", buffer);
stream.write(buffer.as_bytes()).unwrap();
println!("Sent {}, awaiting reply...", buffer);
} }
Err(error) => { Err(error) => {
println!("error: {error}"); println!("error: {error}");
@ -25,10 +23,4 @@ fn main() {
} }
} }
} }
},
Err(e) => {
println!("Failed to connect: {}", e);
}
}
println!("Terminated.");
} // the stream is closed here } // the stream is closed here