com.dalsemi.tininet.dhcp
Class DHCPClient

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--com.dalsemi.tininet.dhcp.DHCPClient

public class DHCPClient
extends Thread

The DHCPClient supports dynamically obtaining a new IP Address or reclaiming an IP Address lost on reboot from a DHCP server. Both constructors are passed a DHCPListener so that DHCP status messages can be relayed. After the DHCPClient object is constructed, the process in invoked through the start() method. When the user no longer needs the IP Address it is recommended that the stopDHCP method is called to release the IP to the server and close the socket.

Refer to the following RFCs:

            951 - BOOTSTRAP PROTOCOL (BOOTP)
           1048 - BOOTP Vendor Information Extensions
           2131 - Dynamic Host Configuration Protocol
           2132 - DHCP Options and BOOTP Vendor Extentions
RFC repository http://www.ietf.org/rfc.html


Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
DHCPClient(DHCPListener DL)
          Constructs a dhcp object and intializes for obtaining a new IP.
DHCPClient(DHCPListener DL, byte[] serverIP, byte[] localIP)
          Constructs a dhcp object and intializes to attempt to rebind to previous owned IP that was lost in a reboot.
 
Method Summary
 void addDHCPListener(DHCPListener newListener)
          Adds listener for accepting dhcp status messages.
 void removeDHCPListener(DHCPListener thisListener)
          Removes listener, to discontinue acceptance of status messages.
 void run()
          Starts dhcp thread.
 void stopDHCPThread()
          Stops dhcp thread, releases ip, and closes any open sockets.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, 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

DHCPClient

public DHCPClient(DHCPListener DL)
           throws IllegalStateException
Constructs a dhcp object and intializes for obtaining a new IP.
Parameters:
DL - DHCPListener to report DHCP status messages
See Also:
DHCPListener.java

DHCPClient

public DHCPClient(DHCPListener DL,
                  byte[] serverIP,
                  byte[] localIP)
           throws IllegalStateException
Constructs a dhcp object and intializes to attempt to rebind to previous owned IP that was lost in a reboot.
Parameters:
DL - DHCPListener
serverIP - IP of DHCP server where previous IP was obtained
localIP - IP to obtain
Method Detail

run

public void run()
Starts dhcp thread.
Overrides:
run in class Thread

stopDHCPThread

public void stopDHCPThread()
Stops dhcp thread, releases ip, and closes any open sockets.

addDHCPListener

public void addDHCPListener(DHCPListener newListener)
Adds listener for accepting dhcp status messages.
Parameters:
newListener - DHCPListener for accepting status messages

removeDHCPListener

public void removeDHCPListener(DHCPListener thisListener)
Removes listener, to discontinue acceptance of status messages.
Parameters:
thisListener - DHCPListener to be removed from list