Unsupported library that attempts to punch holes through NAT
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

BindingLifetimeTestDemo.java 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * This file is part of JSTUN.
  3. *
  4. * Copyright (c) 2005 Thomas King <king@t-king.de> - All rights
  5. * reserved.
  6. *
  7. * This software is licensed under either the GNU Public License (GPL),
  8. * or the Apache 2.0 license. Copies of both license agreements are
  9. * included in this distribution.
  10. */
  11. package de.javawi.jstun.test.demo;
  12. import java.util.logging.FileHandler;
  13. import java.util.logging.Handler;
  14. import java.util.logging.Level;
  15. import java.util.logging.Logger;
  16. import java.util.logging.SimpleFormatter;
  17. import de.javawi.jstun.test.BindingLifetimeTest;
  18. public class BindingLifetimeTestDemo {
  19. public static void main(String args[]) {
  20. try {
  21. Handler fh = new FileHandler("logging.txt");
  22. fh.setFormatter(new SimpleFormatter());
  23. Logger.getLogger("de.javawi.stun").addHandler(fh);
  24. Logger.getLogger("de.javawi.stun").setLevel(Level.ALL);
  25. BindingLifetimeTest test = new BindingLifetimeTest("iphone-stun.freenet.de", 3478);
  26. // iphone-stun.freenet.de:3478
  27. // larry.gloo.net:3478
  28. // stun.xten.net:3478
  29. test.test();
  30. boolean continueWhile = true;
  31. while(continueWhile) {
  32. Thread.sleep(5000);
  33. if (test.getLifetime() != -1) {
  34. System.out.println("Lifetime: " + test.getLifetime() + " Finished: " + test.isCompleted());
  35. if (test.isCompleted()) continueWhile = false;
  36. }
  37. }
  38. } catch (Exception e) {
  39. System.out.println(e.getMessage());
  40. e.printStackTrace();
  41. }
  42. }
  43. }