File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Sockets and Internet Protocols and the fly likes hosts in LAN Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "hosts in LAN" Watch "hosts in LAN" New topic
Author

hosts in LAN

S. Ganapathy
Ranch Hand

Joined: Mar 26, 2003
Posts: 194
Hi there,
I am facing one problem while findingout all host machines in the LAN. I want to display all available hosts in the list. Can anybody help me to find all machines (host names/ip addresses) in the local area network
Ganapathy
[ May 16, 2003: Message edited by: S. Ganapathy ]
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
I don't think this is possible short of going through JNI, but I'd love to be corrected on this.
- Peter
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
I don't think this is possible short of going through JNI, but I'd love to be corrected on this.
You need to be able to send and recieve ARP packets to query a LAN. Since Java does not support raw sockets, as Peter says, you will either have to provide your own native library or find one that's already been built. A few months back, Michael Ernest posted a link to a Java ARP library, but I can't seem to find it by searching here or thru Google. We get so many questions on this subject, if I can find the time, I may just try to create one myself.


Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Murali Nanchala
Ranch Hand

Joined: Mar 14, 2001
Posts: 74
Check this out: Jpcap


"It is almost always answered in the API" - Murali Nanchala
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Jpcap doesn't support ARP packets either. It does however support ICMP packets. You could write a dirty ping sweep hack if you knew the LAN's subnet. But even that wouldn't be 100%.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: hosts in LAN