For this exercise a program is open a socket to localhost on port 256 and send the message "hello socket world" before closing the socket.

Catching any exceptions or errors is not required.




use std::io::prelude::*;
use std::net::TcpStream;
 
fn main() {
    // Open a tcp socket connecting to 127.0.0.1:256, no error handling (unwrap)
    let mut my_stream = TcpStream::connect("127.0.0.1:256").unwrap();
 
    // Write 'hello socket world' to the stream, ignoring the result of write
    let _ = my_stream.write(b"hello socket world");
 
} // <- my_stream's drop function gets called, which closes the socket