Checks if a server is running. @param host host @param port server port @return boolean success
(final String host, final int port)
| 302 | * @return boolean success |
| 303 | */ |
| 304 | public static boolean ping(final String host, final int port) { |
| 305 | try { |
| 306 | // connect server with invalid login data |
| 307 | try(ClientSession cs = new ClientSession(host, port, "", "")) { /* no action */ } |
| 308 | return false; |
| 309 | } catch(final LoginException ex) { |
| 310 | // if login was checked, server is running |
| 311 | Util.debug(ex); |
| 312 | return true; |
| 313 | } catch(final IOException ex) { |
| 314 | Util.debug(ex); |
| 315 | return false; |
| 316 | } |
| 317 | } |
| 318 | |
| 319 | /** |
| 320 | * Stops the server. |