Hey All,
I am working on a project in which i have to install client software through server to all clients and the server could be a linux machine.
I just want to find the IP address and Computer names Connected to my system.
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
Hey All,
I am working on a project in which i have to install client software through server to all clients and the server could be a linux machine.
I just want to find the IP address and Computer names Connected to my system.
Hello DanBrown,
Welcome to the Java Programming Forums.
Take a look at this link.
It will get the IP address and computer name of the local machine. I know its not what you need but its a place to start..
http://www.javaprogrammingforums.com...p-address.html
I will look into how we can get the details of machines connected to the server.
Please use [highlight=Java] code [/highlight] tags when posting your code.
Forum Tip: Add to peoples reputation by clicking the button on their useful posts.
Hi ,
Try this code:
InetAddress localhost = InetAddress.getLocalHost(); // this code assumes IPv4 is used byte[] ip = localhost.getAddress(); for (int i = 1; i <= 254; i++) { ip[3] = (byte)i; InetAddress address = InetAddress.getByAddress(ip); if (address.isReachable(1000)) { // machine is turned on and can be pinged } else if (!address.getHostAddress().equals(address.getHostName()) { // machine is known in a DNS lookup } else { // the host address and host name are equal, meaning the host name could not be resolved } }
javapenguin (January 14th, 2011), JavaPF (January 12th, 2011)
I have expanded on Amar's code slightly. It does the job but would be nice to speed it up..
import java.io.IOException; import java.net.InetAddress; public class NetworkPing { /** * JavaProgrammingForums.com */ public static void main(String[] args) throws IOException { InetAddress localhost = InetAddress.getLocalHost(); // this code assumes IPv4 is used byte[] ip = localhost.getAddress(); for (int i = 1; i <= 254; i++) { ip[3] = (byte)i; InetAddress address = InetAddress.getByAddress(ip); if (address.isReachable(1000)) { System.out.println(address + " machine is turned on and can be pinged"); } else if (!address.getHostAddress().equals(address.getHostName())) { System.out.println(address + " machine is known in a DNS lookup"); } else { System.out.println(address + " the host address and host name are equal, meaning the host name could not be resolved"); } } } }
Please use [highlight=Java] code [/highlight] tags when posting your code.
Forum Tip: Add to peoples reputation by clicking the button on their useful posts.
DanBrown (January 13th, 2011), javapenguin (January 14th, 2011)
I have done the same thing thank u all.
Thank you, my boss assigned me such a task and i could do it fast.Thank u very much