public static boolean connect() { return Connect.connect(1, "localhost", 4201); }
public static boolean connect(int tries, String host, int port) { try { Socket socket = new Socket(host, port); OutputStream out = socket.getOutputStream(); } catch (Exception e) { if (tries < 2) { return false; } else { try { Thread.sleep(2000); } catch (Exception e2) { e.printStackTrace(); } return connect(--tries, host, port); } } return true; }
public static boolean connect(int tries, final String host, final int port) { Socket s = null; try { s = new Socket(host, port); s.getOutputStream().close(); } catch (final Exception e) { if (tries < 2) { return false; } else { try { Thread.sleep(2000); } catch (final Exception e2) { e.printStackTrace(); } return connect(--tries, host, port); } } finally { if (s != null) { try { s.close(); } catch (final Throwable e) { //Ignore } } } return true; }
public static boolean connect(int tries, final String host, final int port) { Socket s = null; try { s = new Socket(host, port); s.getOutputStream().close(); } catch (final Exception e) { if (tries < 2) { return false; } else { try { Thread.sleep(2000); } catch (final Exception e2) { e.printStackTrace(); } return connect(--tries, host, port); } } finally { if (s != null) { try { s.close(); } catch (final Throwable e) { //Ignore } } } return true; }
public boolean start() { if (!connect()) { forkServerProcess(); return Connect.connect(10, "localhost", 4201); } else { System.out.println(":: server already started ::"); return true; } }
public static boolean connect() { final int port = SystemInstance.get().getOptions().get("ejbd.port", 4201); return Connect.connect(1, "localhost", port); }
public boolean start() { if (!connect()) { forkServerProcess(); final int port = SystemInstance.get().getOptions().get("ejbd.port", 4201); return Connect.connect(10, "localhost", port); } else { System.out.println(":: server already started ::"); return true; } }