create rust socket server
This commit is contained in:
@@ -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...");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user