MCPcopy Create free account
hub / github.com/MertJSX/folderhost / IsPortAvailable

Function IsPortAvailable

utils/port_utils.go:20–31  ·  view source on GitHub ↗
(port int)

Source from the content-addressed store, hash-verified

18}
19
20func IsPortAvailable(port int) bool {
21 timeout := time.Second
22 conn, err := net.DialTimeout("tcp", net.JoinHostPort("localhost", fmt.Sprintf("%d", port)), timeout)
23 if err != nil {
24 return true
25 }
26 if conn != nil {
27 conn.Close()
28 return false
29 }
30 return true
31}

Callers 2

mainFunction · 0.92
FindAvailablePortFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected