/
githubmirror
/
deno
Обзор
Документация
Войти
/
githubmirror
/
deno
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
cli/lib/util/net.rs
11 строк
565 B
Leo Kettmeir
feat: `deno desktop` subcommand (#33441)
16 июн 2026, 13:41
Не верифицирован
16 июн 2026, 13:41
8398162
Код
Авторство
О чём код?
// Copyright 2018-2026 the Deno authors. MIT license. /// Bind to an ephemeral TCP port on the loopback interface and return the /// number assigned by the kernel. The listener is dropped before returning, /// so the caller is racing against any other process for the port — on /// loopback the window is small enough to be acceptable for ad-hoc service /// ports (DevTools mux, desktop HTTP server, …). pub fn allocate_random_port() -> std::io::Result<u16> { let listener = std::net::TcpListener::bind("127.0.0.1:0")?; Ok(listener.local_addr()?.port()) }