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")
}
}Вывод
listening: true
pub(api) static fn bind(cfg: ServerConfig = ServerConfig{}) -> Server | NetError netС версии. 1.0.0-beta
Параметры
| Имя | Тип |
|---|---|
cfg | ServerConfig = ServerConfig{} |
Возвращает
Ошибки
NetError- `Unavailable` (address in use), `AccessDenied` (privileged port), `ProtocolError` (bad TLS settings).
Эффекты
net
Определено в: std/http/http.oxl:4287