Java program to know in which IP server is running without joining to server and used ServerSocket class in program
Can anyone told me that
how to know in which PC in lan my server is running
-> server is started using ServerSocket class with some port number i use 8888 as port number
-> i have a list of IP address connected to particular pc
Now, how i would know in which IP my server is running without joining that server.
Re: how to know in which PC in lan my server is running
You could add code to your server application so it displays its current IP address?
Try this code
Code :
public class NetInfo {
public static void main(String[] args) {
new NetInfo().say();
}
public void say() {
try {
java.net.InetAddress i = java.net.InetAddress.getLocalHost();
System.out.println(i); // name and IP address
System.out.println(i.getHostName()); // name
System.out.println(i.getHostAddress()); // IP address only
}
catch(Exception e){e.printStackTrace();}
}
}
http://www.javaprogrammingforums.com...s.html#post869