networking - How to get a list of IP connected in same network (subnet) using Java -
How do I get an IP address list for devices connected to my own subnet using Java?
This should work when the host ICMP on your network (ping) (> JDK5) Give Feedback:
Public Zero Checking Host (String Subnet) {Int Timeout = 1000; For (Int i = 1; I <255; i ++) {string host = subnet + "." + I; If (InetAddress.getByName (host) .isReachable (timeout)) {System.out.println (host + "is reachable"); }}}
Call the method for a subnet (1 9-2.168.0.1-254) like this:
checkhost ("192.168. 0 ");
did not test it, but doing something like this should be done. Obviously it only checks the 254 hosts in the previous byte of the IP address ...
Check:
Hope that help
Comments
Post a Comment