Standard Library
class SystemNet
The real network behind the INet interface.
since 0.1.0-alpha.1linuxwindows
- bases
INet
Examples
INet net = SystemNet();
console.writeln(net.connect("127.0.0.1", 1) == None);
true
Methods
connect
connect(string host, int port) -> TcpStream | NoneOpen a real connection to a host and port.
Parameters
- host
- The host name or address.
- port
- The port number.
Returns
The connected stream, or None when the connection fails.
Examples
SystemNet net = SystemNet();
TcpStream? s = net.connect("127.0.0.1", 1);
console.writeln(s == None);
true
listen
listen(int port) -> TcpListenerStart listening on a real port.
Port 0 lets the system choose a free port. The caller checks ok() on the result to see
whether the port could be bound, and calls stop() when done.
Parameters
- port
- The port number to listen on.
Returns
The listener.
Examples
SystemNet net = SystemNet();
TcpListener l = net.listen(0);
console.writeln(l.ok());
l.stop();
true