Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-18-2008, 01:06 PM
Member
 
Join Date: Dec 2007
Posts: 19
JavaEmpires is on a distinguished road
Java failed to reach to a PC in local LAN
Hi all,
I tried to execute the following code
Code:
try{ NetworkInterface ni = NetworkInterface.getByName("eth0"); System.out.println("\nGetting Host Name ...."); InetAddress[] addr = InetAddress.getAllByName("192.168.6.252"); for(int i=0;i<addr.length;i++){ System.out.println("\nHost Name = "+addr[i].getHostName()); System.out.println("\nIs Reachable?? = "+addr[i].isReachable(10)); } } catch(Exception e){ System.out.println("\nError :"+e); e.printStackTrace(); }
and the output I got was :
Code:
Getting Host Name .... Host Name = 192.168.6.252 Is Reachable?? = false
But when i PING to 192.168.6.252 it replies back i.e it is reachable from my computer.
What could be the problem in above code?

Thanx in advance.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 01-24-2008, 07:30 PM
undertow's Avatar
Member
 
Join Date: Jan 2008
Location: Colorado USA
Posts: 12
undertow is on a distinguished road
Send a message via AIM to undertow Send a message via Skype™ to undertow
javadoc mentions "A typical implementation will use ICMP ECHO REQUESTs if the privilege can be obtained, otherwise it will try to establish a TCP connection on port 7 (Echo) of the destination host."

maybe the JVM is unable to get permission to do an ICMP echo, so it tries a TCP connect on port 7. If you are using windows i would have a look at firewall settings. The ping program might have intrinsic privilege elevation for that kind of thing.

or maybe the instantiation of the NetworkInterface(doesnt look like you are using it at all) object could be blocking the request.

Last edited by undertow : 01-24-2008 at 07:32 PM.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Initial SessionFactory creation failed escit Database 1 08-13-2007 04:46 AM
Loading of JSP file failed Heather JavaServer Pages (JSP) and JSTL 2 08-06-2007 02:15 AM
WARN [org.jboss.deployment.JARDeployer] Failed to add deployable jar mary Advanced Java 3 08-01-2007 05:20 PM
Compile failed, messages should have been provided leonard New To Java 2 07-30-2007 06:36 PM
java.net.SocketException: Permission denied: listen failed vitaliy Networking 2 07-09-2007 12:20 PM


All times are GMT +3. The time now is 06:05 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org