/** * Check a binding with the STUN currentServer. * * Note: this function blocks for some time, waiting for a response. * * @return true if the currentServer is usable. */ public boolean checkBinding() { boolean result = false; try { BindingLifetimeTest binding = new BindingLifetimeTest(hostname, port); binding.test(); while (true) { Thread.sleep(5000); if (binding.getLifetime() != -1) { if (binding.isCompleted()) { return true; } } else { break; } } } catch (Exception e) { LOGGER.log(Level.SEVERE, "Exception in checkBinding", e); } return result; } }
public static void main(String args[]) { try { Handler fh = new FileHandler("logging.txt"); fh.setFormatter(new SimpleFormatter()); java.util.logging.Logger.getLogger("de.javawi.stun").addHandler(fh); java.util.logging.Logger.getLogger("de.javawi.stun").setLevel(Level.ALL); BindingLifetimeTest test = new BindingLifetimeTest("jstun.javawi.de", 3478); // iphone-stun.freenet.de:3478 // larry.gloo.net:3478 // stun.xten.net:3478 test.test(); boolean continueWhile = true; while(continueWhile) { Thread.sleep(5000); if (test.getLifetime() != -1) { System.out.println("Lifetime: " + test.getLifetime() + " Finished: " + test.isCompleted()); if (test.isCompleted()) continueWhile = false; } } } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); } } }
public static void main(String args[]) { try { Handler fh = new FileHandler("logging.txt"); fh.setFormatter(new SimpleFormatter()); java.util.logging.Logger.getLogger("de.javawi.stun").addHandler(fh); java.util.logging.Logger.getLogger("de.javawi.stun").setLevel(Level.ALL); BindingLifetimeTest test = new BindingLifetimeTest("jstun.javawi.de", 3478); // iphone-stun.freenet.de:3478 // larry.gloo.net:3478 // stun.xten.net:3478 test.test(); boolean continueWhile = true; while(continueWhile) { Thread.sleep(5000); if (test.getLifetime() != -1) { System.out.println("Lifetime: " + test.getLifetime() + " Finished: " + test.isCompleted()); if (test.isCompleted()) continueWhile = false; } } } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); } } }
/** * Check a binding with the STUN currentServer. * <p/> * Note: this function blocks for some time, waiting for a response. * * @return true if the currentServer is usable. */ public boolean checkBinding() { boolean result = false; try { BindingLifetimeTest binding = new BindingLifetimeTest(hostname, port); binding.test(); while (true) { Thread.sleep(5000); if (binding.getLifetime() != -1) { if (binding.isCompleted()) { return true; } } else { break; } } } catch (Exception e) { LOGGER.log(Level.SEVERE, "Exception in checkBinding", e); } return result; } }
/** * Check a binding with the STUN currentServer. * <p/> * Note: this function blocks for some time, waiting for a response. * * @return true if the currentServer is usable. */ public boolean checkBinding() { boolean result = false; try { BindingLifetimeTest binding = new BindingLifetimeTest(hostname, port); binding.test(); while (true) { Thread.sleep(5000); if (binding.getLifetime() != -1) { if (binding.isCompleted()) { return true; } } else { break; } } } catch (Exception e) { LOGGER.error(e.getMessage(), e); } return result; } }