MCPcopy Create free account
hub / github.com/PasarGuard/node / isPortFree

Function isPortFree

pkg/netutil/port.go:9–16  ·  view source on GitHub ↗
(port int)

Source from the content-addressed store, hash-verified

7)
8
9func isPortFree(port int) bool {
10 ln, err := net.Listen("tcp", fmt.Sprintf(":%d", port))
11 if err != nil {
12 return false
13 }
14 _ = ln.Close()
15 return true
16}
17
18func FindFreePort() int {
19 var apiPort int

Callers 1

FindFreePortFunction · 0.85

Calls 1

CloseMethod · 0.65

Tested by

no test coverage detected