• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Writing DHCP client/server in JAVA

 
KaKa Ng
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic