|
|
|
@ -2,13 +2,35 @@ use std::net::{TcpStream, TcpListener,SocketAddr}; |
|
|
|
use std::io::prelude::*; |
|
|
|
use std::io; |
|
|
|
use std::time::{Duration}; |
|
|
|
use std::thread; |
|
|
|
|
|
|
|
fn main() { |
|
|
|
let address = "127.0.0.1:8000"; |
|
|
|
let address = "192.168.1.77:8000"; |
|
|
|
let mut text = String::new(); |
|
|
|
let mut stream: TcpStream = TcpStream::connect(address).expect("connection failed"); |
|
|
|
let mut outstream = stream.try_clone().unwrap(); |
|
|
|
let mut reader = BufReader::new(stream); |
|
|
|
|
|
|
|
writeln!(stream,"display\n").expect("write failed"); |
|
|
|
write!(outstream,"setsegment 3 on\n").expect("write failed"); |
|
|
|
stream.read_to_string(&mut text).expect("read failed"); |
|
|
|
println!("received: '{}'", text.trim_end()); |
|
|
|
write!(outstream,"setsegment 4 on\n").expect("write failed"); |
|
|
|
stream.read_to_string(&mut text).expect("read failed"); |
|
|
|
println!("received: '{}'", text.trim_end()); |
|
|
|
write!(outstream,"setsegment 5 on\n").expect("write failed"); |
|
|
|
stream.read_to_string(&mut text).expect("read failed"); |
|
|
|
println!("received: '{}'", text.trim_end()); |
|
|
|
write!(outstream,"display\n").expect("write failed"); |
|
|
|
stream.read_to_string(&mut text).expect("read failed"); |
|
|
|
println!("received: '{}'", text.trim_end()); |
|
|
|
thread::sleep(Duration::from_millis(1000)); |
|
|
|
write!(outstream,"setsegment 0 on\n").expect("write failed"); |
|
|
|
stream.read_to_string(&mut text).expect("read failed"); |
|
|
|
println!("received: '{}'", text.trim_end()); |
|
|
|
write!(outstream,"setsegment 6 on\n").expect("write failed"); |
|
|
|
stream.read_to_string(&mut text).expect("read failed"); |
|
|
|
println!("received: '{}'", text.trim_end()); |
|
|
|
write!(outstream,"display\n").expect("write failed"); |
|
|
|
stream.read_to_string(&mut text).expect("read failed"); |
|
|
|
println!("received: '{}'", text.trim_end()); |
|
|
|
} |
|
|
|
|