This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Sockets and Internet Protocols and the fly likes getHostName question Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Reply Bookmark "getHostName question" Watch "getHostName question" New topic
Author

getHostName question

ram ba
Greenhorn

Joined: Sep 19, 2006
Posts: 4
Hello,

In my code I have like this.

// Changed the IP to a.b.c.d
InetAddress ad = InetAddress.getByName("a.b.c.d");
ip = ad.getHostAddress();
hn = ad.getHostName();

// ip shows a.b.c.d
// hn also shows a.b.c.d instead of the actual host name.

When I am trying to do the nslookup for this a.b.c.d, I can get the DNS entry and displays the host/canonical name

Can you please tell my why it shows IP and how to get the Hostname itself. Also is there a api that I can use to see if the DNS entry for this IP is missing.

Thanks
Lewin Chan
Ranch Hand

Joined: Oct 10, 2001
Posts: 214
What happens if you nslookup the IP Address?

Perhaps the reverse lookup zones haven't been done correctly.


I have no java certifications. This makes me a bad programmer. Ignore my post.
ram ba
Greenhorn

Joined: Sep 19, 2006
Posts: 4
nslookup gives me the correct data for hostname. But not sure why getHostAddress() does not. The same code works for other IPs and not for some.

What is this reverse lookup zones?

Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: getHostName question
 
Similar Threads
Tomcat 6 and DNS Lookup
inetaddress dns?
URL Posting and NSLOOKUP
Open ports in a huge web application.
Https connection using a hostname not a url.