create rust socket server

This commit is contained in:
2026-02-25 05:01:01 -06:00
parent bb626045a3
commit db318bcf8a
2 changed files with 41 additions and 4 deletions

View File

@@ -1,3 +1,14 @@
use std::net::TcpStream;
fn main() {
println!("Hello, world!");
}
if let Ok(stream) = TcpStream::connect("127.0.0.1:8080") {
println!("Connected to the server!");
let ip_result = stream.peer_addr();
if ip_result.is_ok() {
println!("{}", ip_result.unwrap());
}
} else {
println!("Couldn't connect to server...");
}
}