OxL Reference

method Server.bind

Binds and listens.

Example:

oxl✓ checked in CI
use std.http { Server, ServerConfig }

fn main() io, net {
  match Server.bind(ServerConfig{ port: 0 }) {
    Server s => {
      print("listening: {s.port() > 0}")
      s.close()
    }
    NetError _ => print("cannot bind")
  }
}
Output
listening: true
pub(api) static fn bind(cfg: ServerConfig = ServerConfig{}) -> Server | NetError  net

Since. 1.0.0-beta

Parameters

NameType
cfgServerConfig = ServerConfig{}

Returns

Server

Errors

  • NetError
  • `Unavailable` (address in use), `AccessDenied` (privileged port), `ProtocolError` (bad TLS settings).

Effects

net

Defined in: std/http/http.oxl:4287

See also