• Post Reply Bookmark Topic Watch Topic
  • New Topic

network lookup for other hosts in local network

 
Pinda Ros
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can anyone tellme if they know, how can we find the hosts in a lan using java?
im aware i could use runtime.exec and netview in windows or something similar on linux but i would prefer using portable code in java.
the reason i want to do this is because im developing a lan chat which the application is going to be client and the server as well,so i wanted to click to that button for example and show the other host on the lan.
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Pinda,
As I told you in JIG Intermediate, this is not a task that Java can handle without third party libraries or native code since it requires raw sockets. Most of us are hopeful that Sun will eventually drop their specious argument that since raw socket creation requires SU privaleges on Unix boxes that they can't guarantee uniform implemention. What you need is to be able to create either ICMP packets and do a ping sweep on the lan or better ARP packets to directly querry the lan. There is free third party libray that you could use called JPcap that might help you out. The catch is, that you will need to be very proficient in low level network protocols, since very few methods are provided. You have to set public fields in the instantiated packets to do your work.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!