aspose file tools*
The moose likes Sockets and Internet Protocols and the fly likes Writing DHCP client/server in JAVA Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Writing DHCP client/server in JAVA" Watch "Writing DHCP client/server in JAVA" New topic
Author

Writing DHCP client/server in JAVA

KaKa Ng
Greenhorn

Joined: Sep 21, 2003
Posts: 1
I would like to bulid something that has DHCP functionality. However, I found the API of java are all on top of layer 3. Whenever it creates a socket, it binds to an IP and a port. In such case, how can I implement DHCP (if without native code?) Any idea?
In particular in client side,
I design a DHCPMessage class to represent DHCP packet
I send a DHCP Discover message to a broadcast address 255.255.255.255, with my MAC address
I used Ethereal to dump packets on the Ethernet
I find my DHCP Discover packets successfully sending out, and the DHCP server in my LAN replies with a DHCP Offer message to my MAC address.
However, my client cannot receive it although the MAC address and port is correct, it contains no IP
Any ideas how to solve?
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Indeed. Java doesn't offer sufficiently low-level access to the network stack to implement DHCP in 100% Java -- you would need to use native methods (or a library that itself uses native methods.)


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Writing DHCP client/server in JAVA