MCPcopy Create free account
hub / github.com/NativeScript/SimDeck / choose_available_service_port_for_bind

Function choose_available_service_port_for_bind

packages/server/src/main.rs:2437–2445  ·  view source on GitHub ↗
(preferred: u16, bind: IpAddr)

Source from the content-addressed store, hash-verified

2435}
2436
2437fn choose_available_service_port_for_bind(preferred: u16, bind: IpAddr) -> anyhow::Result<u16> {
2438 let start = preferred.max(1024);
2439 for port in start..=u16::MAX {
2440 if port_available(bind, port) {
2441 return Ok(port);
2442 }
2443 }
2444 anyhow::bail!("No available SimDeck service port at or above {start}")
2445}
2446
2447fn port_available(bind: IpAddr, port: u16) -> bool {
2448 if bind.is_unspecified() && TcpListener::bind((Ipv4Addr::LOCALHOST, port)).is_err() {

Callers 1

start_project_serviceFunction · 0.85

Calls 2

maxMethod · 0.80
port_availableFunction · 0.70

Tested by

no test coverage detected