use std::io::{self, Read, Write};
use std::net::{SocketAddr, TcpStream};
use std::time::Duration;
fn main() -> io::Result<()> {
// Connect to the server
let timeout_duration = Duration::from_millis(500);
let server_address: SocketAddr = "127.0.0.1:1026".parse().expect("Invalid server address");
let mut stream = TcpStream::connect_timeout(&server_address,timeout_duration)?;
// Message to be sent to the server
let message = "Hello, server!";
// Send the message to the server
//stream.write_all(message.as_bytes())?;
// Read the response from the server
let mut buffer = [0; 1024];
let size = stream.read(&mut buffer)?;
// Print the response from the server
let response = String::from_utf8_lossy(&buffer[0..size]);
println!("{}", response);
Ok(())
}