CodeGuru Forums -
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic Newsletters VB Forums Developer.com


Newest CodeGuru.com Articles:

  • Installing SQL Server 2008
  • Writing UDFs for Firebird Embedded SQL Server
  • [Updated] Shutdown Manager
  • Building Windows Azure Cloud Service Applications with Azure Storage and the Azure SDK

  • Search CodeGuru:
     



    Go Back   CodeGuru Forums > .NET Programming > C-Sharp Programming
    FAQ Members List Calendar Search Today's Posts Mark Forums Read

    C-Sharp Programming Post questions, answers, and comments about C#.

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1    
    Old November 5th, 2009, 04:37 AM
    Victor Kulichkin Victor Kulichkin is offline
    Member
     
    Join Date: Aug 2001
    Posts: 64
    Victor Kulichkin is an unknown quantity at this point (<10)
    Host name via Dns.GetHostEntry(ip);

    Hi,

    I have a problem with resolving a host name (via IP) for some hosts. For that operation I use the following method:

    Code:
                string ip;
                try
                {
                   ...
                    IPHostEntry iphost = Dns.GetHostEntry(ip);
                   ......
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Unable to process the request because " +
                        "the following problem occured:" + Environment.NewLine +
                        ex.Message,
                        "Exception for " + ip);
                }
    For some hosts I get the exception: "No such host....". However if I replace Dns.GetHostEntry(ip) on Dns.Resolve(ip), then it works well. But I cannot use Resolve() because that method is obsolete.

    Ideas?
    Reply With Quote
      #2    
    Old November 5th, 2009, 08:00 AM
    boudino's Avatar
    boudino boudino is offline
    Senior Member
     
    Join Date: Mar 2004
    Location: Prague, Czech Republic, EU
    Posts: 1,342
    boudino is a splendid one to behold (750+)boudino is a splendid one to behold (750+)boudino is a splendid one to behold (750+)boudino is a splendid one to behold (750+)boudino is a splendid one to behold (750+)boudino is a splendid one to behold (750+)boudino is a splendid one to behold (750+)
    Re: Host name via Dns.GetHostEntry(ip);

    It seems that GetHostEntry() is ready for IPv6 while Resolve() expects only IPv4. Can this be the difference? Something in net infrastructure?
    __________________
    • Make it run.
    • Make it right.
    • Make it fast.
    Don't hesitate to rate my post.
    Reply With Quote
      #3    
    Old November 5th, 2009, 09:27 AM
    Victor Kulichkin Victor Kulichkin is offline
    Member
     
    Join Date: Aug 2001
    Posts: 64
    Victor Kulichkin is an unknown quantity at this point (<10)
    Re: Host name via Dns.GetHostEntry(ip);

    it is an old problem :

    http://msdn.microsoft.com/en-us/library/ms143998.aspx

    IPv4 will live long time, I read that 90% of networks use Ipv4.

    Perhaps Resolve() uses also the C deprecated functions: gethostbyaddress() and gethostbyname(). MS recommend to replace them on getnameinfo().

    Last edited by Victor Kulichkin; November 5th, 2009 at 09:30 AM.
    Reply With Quote
    Reply

    Bookmarks
    Go Back   CodeGuru Forums > .NET Programming > C-Sharp Programming


    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    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
    Forum Jump


    All times are GMT -5. The time now is 12:58 AM.



    Acceptable Use Policy

    internet.comMediabistrojusttechjobs.comGraphics.com

    WebMediaBrands Corporate Info


    Advertise | Newsletters | Feedback | Submit News

    Legal Notices | Licensing | Permissions | Privacy Policy


    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
    Copyright WebMediaBrands Inc. 2002-2009