std-module

std::net: network primitives

Separate address values from socket resources. An address describes a destination or binding; constructing one does not open a connection. TCP uses a stream, UDP sends discrete datagrams. Expected stdout (not executed): true 8080 Common mistake: Treating a parsed socket address as an established connection.

Formal Syntax & Structure

rust syntaxrust
use std::net::{IpAddr, SocketAddr, TcpListener, TcpStream, UdpSocket};

Working Example

Example Snippetrust
fn main() {    use std::net::SocketAddr;    let endpoint: SocketAddr = "127.0.0.1:8080".parse().unwrap();    println!("{} {}", endpoint.ip().is_loopback(), endpoint.port());}
Rust Reference