You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

client.rs 579B

1234567891011121314151617181920212223
  1. use std::net::TcpStream;
  2. fn main() {
  3. let stream = TcpStream::connect("127.0.0.1:8080");
  4. if stream.is_ok() {
  5. println!("Connected to the server!");
  6. } else {
  7. println!("Couldn't connect to server...");
  8. }
  9. loop {
  10. let mut buffer = String::new();
  11. match std::io::stdin().read_line(&mut buffer){
  12. Ok(_n) => {
  13. println!("{}", buffer);
  14. }
  15. Err(_error) =>{
  16. println!("Fehlerhafte Eingabe!");
  17. break;
  18. }
  19. }
  20. }
  21. } // the stream is closed here