Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > performing reverse DNS lookup with InetAddress

Reply
Thread Tools

performing reverse DNS lookup with InetAddress

 
 
Madhur Ahuja
Guest
Posts: n/a
 
      08-28-2004

Hello

I use *InetAddress.getByName("host").getHostName()* to get the host name
from IP Address .
Problem is that this method doesn't do error checking i.e. when a IP address
cannot be resolved, it returns the IP Address in text format rather than the
exception.

Is there any way I can detect whether IP address was successfully resolved
or not.



--
Winners dont do different things, they do things differently.

Madhur Ahuja
India

Homepage : http://madhur.netfirms.com
Email : madhur<underscore>ahuja<at>yahoo<dot>com





 
Reply With Quote
 
 
 
 
Paul Lutus
Guest
Posts: n/a
 
      08-29-2004
Madhur Ahuja wrote:

>
> Hello
>
> I use *InetAddress.getByName("host").getHostName()* to get the host name
> from IP Address .
> Problem is that this method doesn't do error checking i.e. when a IP
> address cannot be resolved, it returns the IP Address in text format
> rather than the exception.
>
> Is there any way I can detect whether IP address was successfully resolved
> or not.


Say again? You just explained how to do it, then asked how to do it. If the
call returns an IP address, not a site name, the address wasn't resolved.

Using:

String s = InetAddress.getByAddress(new byte[] {(byte)64,(byte)226,(byte)42
(byte)135}).getHostName();

If after the call, String s equals a textual IP, the lookup failed:

if (s.matches("\\d+\\.\\d+\\.\\d+\\.\\d+"))
{
System.out.println("Address not resolved.");
}

--
Paul Lutus
http://www.arachnoid.com

 
Reply With Quote
 
 
 
Reply

Thread Tools

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Reverse DNS lookup? ga rg Ruby 2 08-06-2008 11:59 AM
reverse DNS lookup =?Utf-8?B?RGFuIE5hc2g=?= ASP .Net 0 10-14-2004 09:05 AM
Creating DNS Reverse Lookup zones, and PTR records using VBScript and WMI Rahul Apte ASP General 0 04-27-2004 11:43 AM
how to do a reverse ip lookup of a DNS server ? PHP2 Perl Misc 1 04-15-2004 05:13 PM
DNS question - reverse DNS getting cluttered Jose Padilla Computer Support 0 01-21-2004 10:29 PM



Advertisments