/** * {@inheritDoc} */ @Override public void connect(String host, int port) throws ConnectException { if (!isConnected()) { try { if (!connectionException) { log.info("KryoNet: Connecting to " + host + ":" + port); } startClient(host, port); log.info("KryoNet: Connection established!"); connectionException = false; } catch (Exception exception) { if (!connectionException) { log.info("KryoNet: Connection to the server failed."); } connectionException = true; stopClient(); if (log.isTraceEnabled()) { log.trace("connect()", exception); } ConnectException e = new ConnectException(exception.getMessage()); e.initCause(exception); throw e; // NOPMD root cause exception is set } } }