MCPcopy
hub / github.com/fatedier/frp / getFreeTCPPort

Function getFreeTCPPort

client/service_test.go:34–44  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

32}
33
34func getFreeTCPPort(t *testing.T) int {
35 t.Helper()
36
37 ln, err := net.Listen("tcp", "127.0.0.1:0")
38 if err != nil {
39 t.Fatalf("listen on ephemeral port: %v", err)
40 }
41 defer ln.Close()
42
43 return ln.Addr().(*net.TCPAddr).Port
44}
45
46func TestRunStopsStartedComponentsOnInitialLoginFailure(t *testing.T) {
47 port := getFreeTCPPort(t)

Calls 3

CloseMethod · 0.65
ListenMethod · 0.45
AddrMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…