Dns.GetHostEntry .NET 2.0

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • RWF

    #1

    Dns.GetHostEntry .NET 2.0

    I am trying to do a reverse DNS lookup using Dns.GetHostEntr y 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.GetHostByAd dress 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.GetHostEntr y(IPAddress.Par se("207.46.130. 108"));
    vs.
    Dns.GetHostByAd dress(IPAddress .Parse("207.46. 130.108"));


  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: Dns.GetHostEntr y .NET 2.0

    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]
    - mvp@spam.guard. caspershouse.co m

    "RWF" <RWF@discussion s.microsoft.com > wrote in message
    news:225E4C39-8C53-409A-9C82-CBB94B89EEB4@mi crosoft.com...[color=blue]
    >I am trying to do a reverse DNS lookup using Dns.GetHostEntr y 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.GetHostByAd dress 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.GetHostEntr y(IPAddress.Par se("207.46.130. 108"));
    > vs.
    > Dns.GetHostByAd dress(IPAddress .Parse("207.46. 130.108"));
    >
    >[/color]


    Comment

    • William Stacey [MVP]

      #3
      Re: Dns.GetHostEntr y .NET 2.0

      Does this blow up also?

      IPHostEntry he = Dns.GetHostEntr y("207.46.130.1 08");
      if (he.Aliases.Len gth == 0)
      {
      Console.WriteLi ne("No host name by that address.");
      return;
      }
      foreach(string alias in he.Aliases)
      {
      Console.WriteLi ne(alias);
      }

      --
      William Stacey [MVP]

      "RWF" <RWF@discussion s.microsoft.com > wrote in message
      news:225E4C39-8C53-409A-9C82-CBB94B89EEB4@mi crosoft.com...[color=blue]
      >I am trying to do a reverse DNS lookup using Dns.GetHostEntr y 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.GetHostByAd dress 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.GetHostEntr y(IPAddress.Par se("207.46.130. 108"));
      > vs.
      > Dns.GetHostByAd dress(IPAddress .Parse("207.46. 130.108"));
      >
      >[/color]


      Comment

      • RWF

        #4
        Re: Dns.GetHostEntr y .NET 2.0

        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:
        [color=blue]
        > Does this blow up also?
        >
        > IPHostEntry he = Dns.GetHostEntr y("207.46.130.1 08");
        > if (he.Aliases.Len gth == 0)
        > {
        > Console.WriteLi ne("No host name by that address.");
        > return;
        > }
        > foreach(string alias in he.Aliases)
        > {
        > Console.WriteLi ne(alias);
        > }
        >
        > --
        > William Stacey [MVP]
        >
        > "RWF" <RWF@discussion s.microsoft.com > wrote in message
        > news:225E4C39-8C53-409A-9C82-CBB94B89EEB4@mi crosoft.com...[color=green]
        > >I am trying to do a reverse DNS lookup using Dns.GetHostEntr y 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.GetHostByAd dress 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.GetHostEntr y(IPAddress.Par se("207.46.130. 108"));
        > > vs.
        > > Dns.GetHostByAd dress(IPAddress .Parse("207.46. 130.108"));
        > >
        > >[/color]
        >
        >
        >[/color]

        Comment

        Working...