Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Listing Machines in a LAN

 
Prashant Sehgal
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I was going through the InetAddess/NetworkInterface family of classes and was wondering if it was possible to use the java.net library to list all the machines in a LAN? I tried my hand at it and was not quite sure what to do. Anybody here tried anything like that?
 
Sushil Sharma
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The host on which your application runs, knows other hosts -- on same LAN -- via ARP protocol. And these IP addresses are not available to JVM.

The only way I can think is to get IP subnet address of your host, and try

for (all host addresses on the subnet) {
InetAddress inet = InetAddress.getByAddress(address);
inet.isReachable();
}

Google to check if someone has written this type of utility.
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If it's a Windows network then possibly JCIFS could do that for you.
 
Prashant Sehgal
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys. I will give these things a shot before I come back with more questions .
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic