471,325 Members | 1,548 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,325 software developers and data experts.

Dns.GetHostEntry .NET 2.0

RWF
I am trying to do a reverse DNS lookup using Dns.GetHostEntry in .NET 2.0,
but it seems to kind of crap out when the result is an answer with multiple
records. It doesnt seem to give any type of answer.

The old Dns.GetHostByAddress seems to work partially by atleast returning 1
IpHostEntry, but it has been deprecated.

Any ideas on how to retrieve the multiple records?

example:
Dns.GetHostEntry(IPAddress.Parse("207.46.130.108") );
vs.
Dns.GetHostByAddress(IPAddress.Parse("207.46.130.1 08"));
Jan 9 '06 #1
3 7142
RWF,

My guess is that they cleaned up the call so that if there is not a DNS
entry for this IP address (and there is not), then it throws an exception to
indicate so (a better solution would have been to return null, in my
opinion).

However, I would say it is not a bad thing to throw an exception, after
all, there is no host entry to be found to begin with!

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"RWF" <RW*@discussions.microsoft.com> wrote in message
news:22**********************************@microsof t.com...
I am trying to do a reverse DNS lookup using Dns.GetHostEntry in .NET 2.0,
but it seems to kind of crap out when the result is an answer with
multiple
records. It doesnt seem to give any type of answer.

The old Dns.GetHostByAddress seems to work partially by atleast returning
1
IpHostEntry, but it has been deprecated.

Any ideas on how to retrieve the multiple records?

example:
Dns.GetHostEntry(IPAddress.Parse("207.46.130.108") );
vs.
Dns.GetHostByAddress(IPAddress.Parse("207.46.130.1 08"));

Jan 10 '06 #2
Does this blow up also?

IPHostEntry he = Dns.GetHostEntry("207.46.130.108");
if (he.Aliases.Length == 0)
{
Console.WriteLine("No host name by that address.");
return;
}
foreach(string alias in he.Aliases)
{
Console.WriteLine(alias);
}

--
William Stacey [MVP]

"RWF" <RW*@discussions.microsoft.com> wrote in message
news:22**********************************@microsof t.com...
I am trying to do a reverse DNS lookup using Dns.GetHostEntry in .NET 2.0,
but it seems to kind of crap out when the result is an answer with
multiple
records. It doesnt seem to give any type of answer.

The old Dns.GetHostByAddress seems to work partially by atleast returning
1
IpHostEntry, but it has been deprecated.

Any ideas on how to retrieve the multiple records?

example:
Dns.GetHostEntry(IPAddress.Parse("207.46.130.108") );
vs.
Dns.GetHostByAddress(IPAddress.Parse("207.46.130.1 08"));

Jan 10 '06 #3
RWF
It doesnt blow up, it just fails to return a HostName for the IPHostEntry,
but 207.46.130.108 is an IP for Microsoft.com, so there has to be something
there. When I go to dnsstuff.com and do a reverse lookup on that IP, maybe
10-15 results are returned.

"William Stacey [MVP]" wrote:
Does this blow up also?

IPHostEntry he = Dns.GetHostEntry("207.46.130.108");
if (he.Aliases.Length == 0)
{
Console.WriteLine("No host name by that address.");
return;
}
foreach(string alias in he.Aliases)
{
Console.WriteLine(alias);
}

--
William Stacey [MVP]

"RWF" <RW*@discussions.microsoft.com> wrote in message
news:22**********************************@microsof t.com...
I am trying to do a reverse DNS lookup using Dns.GetHostEntry in .NET 2.0,
but it seems to kind of crap out when the result is an answer with
multiple
records. It doesnt seem to give any type of answer.

The old Dns.GetHostByAddress seems to work partially by atleast returning
1
IpHostEntry, but it has been deprecated.

Any ideas on how to retrieve the multiple records?

example:
Dns.GetHostEntry(IPAddress.Parse("207.46.130.108") );
vs.
Dns.GetHostByAddress(IPAddress.Parse("207.46.130.1 08"));


Jan 10 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by ad | last post: by
1 post views Thread by Scott J. Peterson, MCSD, MCPSB, MCT | last post: by
2 posts views Thread by The Grim Reaper | last post: by
2 posts views Thread by The Grim Reaper | last post: by
7 posts views Thread by kvnsdr | last post: by
5 posts views Thread by =?Utf-8?B?UVNJRGV2ZWxvcGVy?= | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.