MCPcopy Index your code
hub / github.com/cortesi/devd / pickPort

Function pickPort

server.go:37–53  ·  view source on GitHub ↗
(addr string, low int, high int, tls bool)

Source from the content-addressed store, hash-verified

35)
36
37func pickPort(addr string, low int, high int, tls bool) (net.Listener, error) {
38 firstTry := 80
39 if tls {
40 firstTry = 443
41 }
42 hl, err := net.Listen("tcp", fmt.Sprintf("%v:%d", addr, firstTry))
43 if err == nil {
44 return hl, nil
45 }
46 for i := low; i < high; i++ {
47 hl, err := net.Listen("tcp", fmt.Sprintf("%v:%d", addr, i))
48 if err == nil {
49 return hl, nil
50 }
51 }
52 return nil, fmt.Errorf("Could not find open port.")
53}
54
55func getTLSConfig(path string) (t *tls.Config, err error) {
56 config := &tls.Config{}

Callers 2

ServeMethod · 0.85
TestPickPortFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestPickPortFunction · 0.68