OxL Reference

method TcpStream.connectHost

Resolves host (a name or numeric address) and connects to the first address that accepts.

Example:

oxl✓ checked in CI
use std.net { TcpStream }

fn main() io, net {
  match TcpStream.connectHost("", 80, 1s) {
    TcpStream c => {
      print("connected")
      _ = c.close()
    }
    NetError _ => print("empty host rejected")
  }
}
Output
empty host rejected
pub(api) static fn connectHost(host: str, port: u16, timeout: Duration? = none) -> TcpStream | NetError  net

Since. 1.0.0-beta

Parameters

NameType
hoststr
portu16
timeoutDuration? = none

Returns

TcpStream

Errors

  • NetError
  • `Unavailable` (name not found, refused), `Timeout`, `AccessDenied`, `Cancelled`.

Effects

net

Defined in: std/net/net.oxl:520

See also