MCPcopy Create free account
hub / github.com/google/gapid / findFreePort

Function findFreePort

core/java/jdwp/test/test.go:39–46  ·  view source on GitHub ↗

findFreePort returns a currently free TCP port on the localhost. There are two potential issues with this function: * There is the potential for the port to be taken between the function returning and the port actually being used. * The system _may_ hold on to the socket after it has been told to cl

()

Source from the content-addressed store, hash-verified

37// * The system _may_ hold on to the socket after it has been told to close.
38// Because of these issues, there is a potential for flakiness.
39func findFreePort() (int, error) {
40 dummy, err := net.Listen("tcp", ":0")
41 if err != nil {
42 return 0, err
43 }
44 defer dummy.Close()
45 return dummy.Addr().(*net.TCPAddr).Port, nil
46}
47
48// JavaSource is a map of file name 'foo.java' to the source code.
49type JavaSource map[string]string

Callers 1

BuildRunAndConnectFunction · 0.85

Calls 3

AddrMethod · 0.80
CloseMethod · 0.65
ListenMethod · 0.45

Tested by

no test coverage detected