English 中文(简体)
系统.Net.Dns.GetHost Addresses(“”)
原标题:System.Net.Dns.GetHostAddresses("")

我一直在处理一项申请,如果我的摄影测量和测验科由于英国航天中心而倒台,那么开始这项工作可能很缓慢。 我的ISP昨天被缩减了3个小时,因此,我对我所补充的这部法典不抱多少看法,直到我发现,开始这项工作总是缓慢。 该守则本应归还你的IP地址,我对链接的解读表明,这一联系应当立即进行,但至少是我的机器。

昨天,在互联网上台之前,我把我升级(纪念)升格为XP SP3,并存在其他问题。

因此,我的问题/要求:

  1. Am I doing this right?
  2. If you run this on your machine does it take 39 seconds to return your IP address? It does on mine.

另一项说明是,我进行了包装,第一份申请是NOT在电线上,但第二次是这么做的,得到了迅速的答复。 因此,问题是,除了大脑外,我还失踪的“三党”中所发生的情况。

最后一份说明。 如果我解决全国住户调查,情况就好了。

Public Class Form1

 http://msdn.microsoft.com/en-us/library/system.net.dns.gethostaddresses.aspx
 
 excerpt
 The GetHostAddresses method queries a DNS server 
 for the IP addresses associated with a host name.
 
 If hostNameOrAddress is an IP address, this address 
 is returned without querying the DNS server.
 
 When an empty string is passed as the host name, 
 this method returns the IPv4 addresses of the local host 

Private Sub Button1_Click(ByVal sender As System.Object, _
                          ByVal e As System.EventArgs) Handles Button1.Click

    Dim stpw As New Stopwatch
    stpw.Reset()
    stpw.Start()
     originally Dns.GetHostEntry, but slow also 
    Dim myIPs() As System.Net.IPAddress = System.Net.Dns.GetHostAddresses("")
    stpw.Stop()

    Debug.WriteLine(" " & stpw.Elapsed.TotalSeconds)
    If myIPs.Length > 0 Then Debug.WriteLine(" " & myIPs(0).ToString)
     debug
     39.8990525
     192.168.1.2

    stpw.Reset()
    stpw.Start()
     originally Dns.GetHostEntry, but slow also 
    myIPs = System.Net.Dns.GetHostAddresses("www.vbforums.com")
    stpw.Stop()

    Debug.WriteLine(" " & stpw.Elapsed.TotalSeconds)
    If myIPs.Length > 0 Then Debug.WriteLine(" " & myIPs(0).ToString)
     debug
     0.042212
     63.236.73.220
End Sub

End Class
最佳回答

See post #7 here Fix

问题回答
 A little power shell testing:  Comments marked *



 *returns in < 1 sec.
 PS C:Documents and SettingsMyPC> [System.Net.Dns]::GetHostAddresses("www.msn.com")


 IPAddressToString : 65.55.17.27
 Address           : 454113089
 AddressFamily     : InterNetwork
 ScopeId           :
 IsIPv6Multicast   : False
 IsIPv6LinkLocal   : False
 IsIPv6SiteLocal   : False

 IPAddressToString : 65.55.17.26
 Address           : 437335873
 AddressFamily     : InterNetwork
 ScopeId           :
 IsIPv6Multicast   : False
 IsIPv6LinkLocal   : False
 IsIPv6SiteLocal   : False


 *takes about 40 seconds
 PS C:Documents and SettingsMyPC> [System.Net.Dns]::GetHostAddresses("")


 IPAddressToString : 192.168.1.2
 Address           : 33663168
 AddressFamily     : InterNetwork
 ScopeId           :
 IsIPv6Multicast   : False
 IsIPv6LinkLocal   : False
 IsIPv6SiteLocal   : False


 *returns in < 1 sec.
 PS C:Documents and SettingsMyPC> [System.Net.Dns]::GetHostAddresses("192.168.1.2")


 IPAddressToString : 192.168.1.2
 Address           : 33663168
 AddressFamily     : InterNetwork
 ScopeId           :
 IsIPv6Multicast   : False
 IsIPv6LinkLocal   : False
 IsIPv6SiteLocal   : False


 *takes about 40 seconds
 PS C:Documents and SettingsMyPC> [System.Net.Dns]::GetHostAddresses("")


 IPAddressToString : 192.168.1.2
 Address           : 33663168
 AddressFamily     : InterNetwork
 ScopeId           :
 IsIPv6Multicast   : False
 IsIPv6LinkLocal   : False
 IsIPv6SiteLocal   : False


 *i thought this should return several addresses
 PS C:Documents and SettingsMyPC> [System.Net.Dns]::GetHostAddresses("localhost")


 IPAddressToString : 127.0.0.1
 Address           : 16777343
 AddressFamily     : InterNetwork
 ScopeId           :
 IsIPv6Multicast   : False
 IsIPv6LinkLocal   : False
 IsIPv6SiteLocal   : False



 PS C:Documents and SettingsMyPC>




相关问题
Is Shared ReadOnly lazyloaded?

I was wondering when I write Shared ReadOnly Variable As DataType = New DataType() Or alternatively Shared ReadOnly Variable As New DataType() Is it lazy loaded or as the instance initializes? ...

Entertaining a baby with VB.NET

I would like to write a little application in VB.NET that will detect a baby s cry. How would I get started with such an application?

Choose Enter Rather than Pressing Ok button

I have many fields in the page and the last field is a dropdown with list of values. When I select an item in a dropdown and press Enter, it doesn t do the "Ok". Instead I have to manually click on Ok ...

ALT Key Shortcuts Hidden

I am using VS2008 and creating forms. By default, the underscore of the character in a textbox when using an ampersand is not shown when I run the application. ex. "&Goto Here" is not ...

Set Select command in code

On button Click I want to Set the Select command of a Gridview. I do this and then databind the grid but it doesn t work. What am i doing wrong? protected void bttnView_Click(object sender, ...

Hover tooltip on specific words in rich text box?

I m trying to create something like a tooltip suddenly hoovering over the mouse pointer when specific words in the richt text box is hovered over. How can this be done?

热门标签