Initial commit: RAIDGuard X Rust/Slint GUI client and server
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
//! Simple test client
|
||||
|
||||
use std::io::{Read, Write};
|
||||
use std::net::TcpStream;
|
||||
|
||||
fn main() {
|
||||
println!("Connecting to 127.0.0.1:8923...");
|
||||
match TcpStream::connect("127.0.0.1:8923") {
|
||||
Ok(mut stream) => {
|
||||
println!("Connected! Sending ping...");
|
||||
let msg = r#"{"id":"test","type":"request","action":"ping","params":{}}"#;
|
||||
stream.write_all(msg.as_bytes()).unwrap();
|
||||
stream.write_all(b"\n").unwrap();
|
||||
|
||||
let mut buf = [0u8; 1024];
|
||||
match stream.read(&mut buf) {
|
||||
Ok(n) => {
|
||||
let response = String::from_utf8_lossy(&buf[..n]);
|
||||
println!("Response: {}", response);
|
||||
}
|
||||
Err(e) => println!("Read error: {}", e),
|
||||
}
|
||||
}
|
||||
Err(e) => println!("Connection failed: {}", e),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user