2 * This file is part of JSTUN.
4 * Copyright (c) 2005 Thomas King <king@t-king.de> - All rights
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.
12 package de.javawi.jstun.test.demo;
14 import java.util.logging.FileHandler;
15 import java.util.logging.Handler;
16 import java.util.logging.Level;
17 import java.util.logging.Logger;
18 import java.util.logging.SimpleFormatter;
20 import de.javawi.jstun.test.BindingLifetimeTest;
22 public class BindingLifetimeTestDemo {
23 public static void main(String args[]) {
25 Handler fh = new FileHandler("logging.txt");
26 fh.setFormatter(new SimpleFormatter());
27 Logger.getLogger("de.javawi.stun").addHandler(fh);
28 Logger.getLogger("de.javawi.stun").setLevel(Level.ALL);
29 BindingLifetimeTest test = new BindingLifetimeTest("iphone-stun.freenet.de", 3478);
30 // iphone-stun.freenet.de:3478
31 // larry.gloo.net:3478
34 boolean continueWhile = true;
35 while(continueWhile) {
37 if (test.getLifetime() != -1) {
38 System.out.println("Lifetime: " + test.getLifetime() + " Finished: " + test.isCompleted());
39 if (test.isCompleted()) continueWhile = false;
42 } catch (Exception e) {
43 System.out.println(e.getMessage());