MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / isFree

Method isFree

java/src/org/openqa/selenium/net/PortProber.java:157–165  ·  view source on GitHub ↗
(String bindHost, int port)

Source from the content-addressed store, hash-verified

155 }
156
157 private static boolean isFree(String bindHost, int port) {
158 try (ServerSocket socket = new ServerSocket()) {
159 socket.setReuseAddress(true);
160 socket.bind(new InetSocketAddress(bindHost, port));
161 return true;
162 } catch (IOException | RuntimeException e) {
163 return false;
164 }
165 }
166
167 static int checkPortIsFree(int port) {
168 if (isFree("localhost", port) && isFree("0.0.0.0", port)) {

Callers 3

checkPortIsFreeMethod · 0.95
assertPortIsFreeFunction · 0.80
assertPortNotFreeFunction · 0.80

Calls 1

bindMethod · 0.80

Tested by

no test coverage detected