Click here to Skip to main content
15,031,132 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want method which gives ip addresses of remote pcs those are in LAN?
Posted
Comments
Monalisa S 19-Nov-10 6:14am
   
@ankur:
i know this method i have tried it but its giving ip addresses of the pc on which i am running this method n not of the pcs connected in LAN
Manfred Rudolf Bihy 19-Nov-10 10:31am
   
What about my answer. Answer 2 should do the trick. Have you tried that? Instead of "www.google.com" use the name of a pc on your LAN.
Monalisa S 20-Nov-10 3:02am
   
i want addresses dynamically of all pcs..
so this method will not help...

Hi Monalisa,

try this:

Java
InetAddress inetAddress = InetAddress.getByName("www.google.com");
byte[] raw = inetAddress.getAddress();


The byte array now contains the IP addresses bytes.

Cheers

Manfred
   
v2
Comments
Ankur\m/ 18-Nov-10 8:05am
   
Edited for code formatting.
Manfred Rudolf Bihy 18-Nov-10 8:07am
   
@Ankur: Sorry! Skipped that step.
My third "have you searched Google" answer for the day. :doh:

See this: Google search - ip address java[^]
   
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900