MCPcopy Create free account
hub / github.com/CovenantSQL/CovenantSQL / testPort

Function testPort

utils/net.go:50–65  ·  view source on GitHub ↗
(bindAddr string, port int, excludeAllocated bool)

Source from the content-addressed store, hash-verified

48}
49
50func testPort(bindAddr string, port int, excludeAllocated bool) bool {
51 addr := net.JoinHostPort(bindAddr, fmt.Sprint(port))
52
53 if excludeAllocated {
54 if _, ok := allocatedPorts.Load(addr); ok {
55 return false
56 }
57 }
58
59 ln, err := net.Listen("tcp", addr)
60 if err != nil {
61 return false
62 }
63 ln.Close()
64 return true
65}
66
67// WaitToConnect returns only when port is ready to connect or canceled by context.
68func WaitToConnect(ctx context.Context, bindAddr string, ports []int, interval time.Duration) (err error) {

Callers 2

WaitForPortsFunction · 0.85
GetRandomPortsFunction · 0.85

Calls 1

CloseMethod · 0.65

Tested by

no test coverage detected