(String bindHost, int port)
| 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)) { |
no test coverage detected