Hei!
> Anybody know how to obtain the information of all the hosts that are in
> the same local network as mine? For example, on Windows, how can I get
> a list of computers' information in the same workgroup?
For this, the Windows uses the SMB protocol. The SMB can be used over
several network protocols, like TCP/IP, NetBIOS. In SMB network, every
host braoadcasts its SMB address to other hosts, that's how you can
browse the network and see the list of hosts.
http://en.wikipedia.org/wiki/Server_Message_Block
> Computers in the same intranet has the same IP address prefix (such as
> 192.168.0.1 through 192.168.0.255). Especially I want to get the list
> of those hosts' IP addresses.
One way to create the list of IP addresses of the hosts of an IP subnet
is to ping the broadcast address of the subnet. If the network is
configured correctly and the ICMP requests are not DENIED or REJECTED by
the firewall rules of the hosts, then all hosts in the network should
reply to your ping. Using those replies, you should be able to create
such list.
> Is any class in package java.net able to do this job? Hope I clearly
> express my problem. Thanks!
You need to find some sort of an interface to ICMP protocol in Java. I
don't know if the java.net has some implementation for this or not.
http://en.wikipedia.org/wiki/ICMP
Juhan
> Anybody know how to obtain the information of all the hosts that are in
> the same local network as mine? For example, on Windows, how can I get
[quoted text clipped - 6 lines]
> Is any class in package java.net able to do this job? Hope I clearly
> express my problem. Thanks!
There is a 3rd party library that can probably do it, called JCIFS. I
have used it to access files on a windows share, but I haven't tried
listing a domain, or workgroup. The API says it can do it though.
http://jcifs.samba.org/src/docs/api/jcifs/smb/SmbFile.html