How to Use std

:net for Networking in Rust

Use std::net::TcpListener to bind to a port and handle incoming TCP connections in Rust.

Use std::net::TcpListener to bind to an address and iterate over incoming connections with incoming().

use std::net::TcpListener;

fn main() {
    let listener = TcpListener::bind("127.0.0.1:7878").unwrap();
    for stream in listener.incoming() {
        let stream = stream.unwrap();
        println!("Connection established!");
    }
}