method Server.bind
Binds and listens.
Example:
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 netSince. 1.0.0-beta
Parameters
| Name | Type |
|---|---|
cfg | ServerConfig = ServerConfig{} |
Returns
Errors
NetError- `Unavailable` (address in use), `AccessDenied` (privileged port), `ProtocolError` (bad TLS settings).
Effects
net
Defined in: std/http/http.oxl:4287