OxL Справочник OxL
РусскийEnglish

method TcpStream.connectHost

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

Example:

oxl✓ проверяется в 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")
  }
}
Вывод
empty host rejected
pub(api) static fn connectHost(host: str, port: u16, timeout: Duration? = none) -> TcpStream | NetError  net

С версии. 1.0.0-beta

Параметры

ИмяТип
hoststr
portu16
timeoutDuration? = none

Возвращает

TcpStream

Ошибки

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

Эффекты

net

Определено в: std/net/net.oxl:520

См. также