MCPcopy
hub / github.com/keploy/keploy / isPortAvailable

Function isPortAvailable

utils/utils.go:1137–1144  ·  view source on GitHub ↗

isPortAvailable checks if a specific port is available on the system

(port uint32)

Source from the content-addressed store, hash-verified

1135
1136// isPortAvailable checks if a specific port is available on the system
1137func isPortAvailable(port uint32) bool {
1138 listener, err := net.Listen("tcp", fmt.Sprintf(":%d", port))
1139 if err != nil {
1140 return false
1141 }
1142 defer listener.Close()
1143 return true
1144}
1145
1146// EnsureAvailablePorts checks if the proxy and DNS ports are available.
1147// If they are available, it returns them unchanged.

Callers 1

EnsureAvailablePortsFunction · 0.85

Calls 1

CloseMethod · 0.65

Tested by

no test coverage detected