use std::net::TcpStream; fn main() { let stream = TcpStream::connect("127.0.0.1:8080"); if stream.is_ok() { println!("Connected to the server!"); } else { println!("Couldn't connect to server..."); } } // the stream is closed here