This week's giveaway is in the Threads forum.
We're giving away four copies of Java Concurrency Live Lessons and have Doug Schmidt on-line!
See this thread for details.
Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

java.net.Inetaddress  RSS feed

 
Rajal Mistry
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi! Friends,
I am trying to write a net work management module , so, in a thread i m calling InetAddress.getByName("200.100.50.15");
wh9ich is on my intranet , so when it is on the n/w the code below shows it is on the network by printing it but as my thread is running and if this system goes out of n/w InetAddress.getByName("200.100.50.15"); should throw a exception and show it is not on network (what i feel), but it is not going into the exception part inside the thread. Now if i come out of my program and again starts it it is going to exception and showing the message
that system is not on n/w .and again if the system is brought back on the network inside the thread it is not showing that
it is on n/w.
Is there anything i m doing worng ..
If anybody can tell a little about the inner implementation of InetAddress, please.
thanx.
code goes here :::
import java.net.*;
public class InetAddressTest
{
public static void main(String args[])
{
SystemsOnNetwork sysonnet=new SystemsOnNetwork();
try
{
sysonnet.th.join();
}catch(Exception ie)
{
}

}
}
class SystemsOnNetwork implements Runnable{

Thread th;
String curr = "200.100.50.15";

SystemsOnNetwork()
{
th = new Thread(this);
th.start();
}

public void run()
{
while (true)
{
try{
InetAddress Inet = InetAddress.getByName(curr); System.out.println(" System is on n/w");
}catch(UnknownHostException uhe){
System.out.println(" System is not on n/w");
}
}
}

}//class
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!