Win a copy of Learning Java by Building Android Games this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

host name from an IP  RSS feed

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends!
can any one tell me how to get the host name of the target system if i know the IP of the system using a java program
Regards
Tarun
 
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no reliable way to map from IP address to host name. However, what you can do is post a request to http://www.internic.com/whois.html and parse the response from your Java code.
Eugene.
 
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is called a reverse DNS lookup (since you are mapping the IP to the hostname instead of the other way around) and, as Eugene says, there is no guarantee that a reverse mapping has actually been defined for a given IP. There is also no guarantee that the reverse mapping gives you the same name that you might use for the forward mapping, because multiple names can be mapped to one single IP.The IP address is that of www.javaranch.com, yet the code above outputs "tut.ejip.net". If you paste this in your browser, you'll see that this is indeed the same machine. This won't work for web servers that host multiple sites using virtual hosts!
- Peter
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!