MCPcopy Create free account
hub / github.com/TraderAlice/OpenAlice / isPortFree

Function isPortFree

scripts/probe-port.ts:35–37  ·  view source on GitHub ↗

* A port only counts as free when BOTH the v4 wildcard (0.0.0.0) and the * loopback (127.0.0.1) bind succeed. One bind is not enough on macOS/BSD: * SO_REUSEADDR (node's default) lets a specific-address bind succeed while * a wildcard listener holds the port — and vice versa — so probing only *

(port: number)

Source from the content-addressed store, hash-verified

33 * 0.0.0.0 each miss one mode; the conjunction catches all four.
34 */
35async function isPortFree(port: number): Promise<boolean> {
36 return (await bindable(port, '0.0.0.0')) && (await bindable(port, '127.0.0.1'))
37}
38
39function bindable(port: number, host: string): Promise<boolean> {
40 return new Promise((res) => {

Callers 1

probeFreePortFunction · 0.70

Calls 1

bindableFunction · 0.70

Tested by

no test coverage detected