1 changed files with 5 additions and 4 deletions
@ -1,13 +1,14 @@ |
|||||
use std::net::{TcpStream, TcpListener}; |
use std::net::{TcpStream, TcpListener,SocketAddr}; |
||||
use std::io::prelude::*; |
use std::io::prelude::*; |
||||
use std::io; |
use std::io; |
||||
|
use std::time::{Duration}; |
||||
|
|
||||
fn main() { |
fn main() { |
||||
let address = "127.0.0.1:8000"; |
let address = "127.0.0.1:8000"; |
||||
let mut text = String::new(); |
let mut text = String::new(); |
||||
let mut stream = TcpStream::connect(address).expect("connection failed"); |
let mut stream: TcpStream = TcpStream::connect(address).expect("connection failed"); |
||||
|
|
||||
write!(stream,"hello from the client!\n").expect("write failed"); |
writeln!(stream,"display\n").expect("write failed"); |
||||
stream.read_to_string(&mut text).expect("read failed"); |
stream.read_to_string(&mut text).expect("read failed"); |
||||
println!("received: '{}'", text.trim_right()); |
println!("received: '{}'", text.trim_end()); |
||||
} |
} |
||||
|
|||||
Loading…
Reference in new issue