com.lightdev.app.ddnscl.net
Class DynDnsIPChecker


java.lang.Object

  extended byjava.lang.Thread

      extended bycom.lightdev.app.ddnscl.net.DynDnsIPChecker

All Implemented Interfaces:
Runnable

public class DynDnsIPChecker
extends Thread

This class uses the web based IP detection service of www.dyndns.org to find out the IP address a machine is connected to the internet under.

This is useful, when a client connects through a router and the client can not determine the IP address under which the router connects to the internet.

The class assumes the reply to be in the format DnyDNS.org used at the time this class was created:



   

     

       Current IP Check

     

     

       Current IP Address: 217.233.199.126

     

   

 

Important: the service at DynDNS.org has a limit of once every 10 minutes.

Version:
1, July 11, 2004
Author:
Ulrich Hilger, Light Development, http://www.lightdev.com, info@lightdev.com, published under the terms and conditions of the GNU General Public License, for details see file gpl.txt in the distribution package of this software as well as any licensing notes inside this documentation

Nested Class Summary
static interface DynDnsIPChecker.DynDnsIPCheckerListener
          A class using a DynDnsIPChecker thread needs to implement this interface inorder to be notified when an IP address was received
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
DynDnsIPChecker(DynDnsIPChecker.DynDnsIPCheckerListener l)
          constructor
 
Method Summary
 void detectIPAddress()
          initiate this thread, i.e. call method 'run' to connect to the given address (default is checkip.dyndns.org) and wait to receive the public IP address returned by respective address
 String getIP()
          get the received IP
 void run()
          run this thread, i.e. connect to the given address (default is checkip.dyndns.org) and wait until the public IP address is returned by respective address.
 void setRequestReceiver(String address)
          set the address to request an IP check at (e.g. checkip.dyndns.org) If the address is not set explicitly with this method, the default address checkip.dyndns.org is used.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DynDnsIPChecker


public DynDnsIPChecker(DynDnsIPChecker.DynDnsIPCheckerListener l)
constructor

Parameters:
l - DynDnsIPCheckerListener the listener to notify when the IP was received
Method Detail

setRequestReceiver


public void setRequestReceiver(String address)
set the address to request an IP check at (e.g. checkip.dyndns.org)

If the address is not set explicitly with this method, the default address checkip.dyndns.org is used.

Parameters:
address - String the address to request an IP at

getIP


public String getIP()
get the received IP

Returns:
String the IP

detectIPAddress


public void detectIPAddress()
initiate this thread, i.e. call method 'run' to connect to the given address (default is checkip.dyndns.org) and wait to receive the public IP address returned by respective address

See Also:
run

run


public void run()
run this thread, i.e. connect to the given address (default is checkip.dyndns.org) and wait until the public IP address is returned by respective address. Once recieved, parse the response, store the IP address found and notify the listener that an IP address is present.


Copyright (c) 2004 Ulrich Hilger