netTCP networking.
Create TCP servers and clients for bidirectional byte-stream communication.
import std::net;
fn main() {
let listener = net.listen(":9000");
let conn = listener.accept();
let msg = conn.read();
conn.write("echo: " + msg);
conn.close();
}
listenCreate a TCP listener bound to the given address.
The address format is "host:port" or ":port".
let listener = net.listen(":9000");
connectConnect to a TCP server at the given address.
Blocks until the connection is established.
let conn = net.connect("localhost:9000");
connect_timeoutConnect to a TCP server with a timeout.
timeout_sec and timeout_usec specify the deadline.
broadcast_exceptBroadcast a message to all connections except the sender.
Used in chat-server patterns to fan out messages.
ListenerA TCP listener bound to an address, waiting for connections.
Created by net.listen(addr).
ConnectionAn established TCP connection for reading and writing.
Obtained from listener.accept() or net.connect(addr).
ListenerMethodsMethods available on a TCP Listener.
ConnectionMethodsMethods available on a TCP Connection.