开发者

Dns.GetHostByAddress() works but Dns.GetHostEntry() doesn't

开发者 https://www.devze.com 2023-04-10 16:52 出处:网络
I changed my code so it no longer uses the deprectaed: Dns.GetHostByAddress(ipaddress); to use: Dns.GetHostEntry(ipaddress);

I changed my code so it no longer uses the deprectaed:

Dns.GetHostByAddress(ipaddress);

to use:

Dns.GetHostEntry(ipaddress);

The problem is I get an exception from Dns.GetHostEntry

No such host is known

SOURCE: System

TARGETSITE: System.Net.IPHostEntry GetAddrInfo(System.String)

If I go back to the deprecated Dns.GetHostByAddress it correctly looks up the hostname from the IP address I give it.

I see t开发者_如何学Pythonhis problem on XP 64bit and Windows 7. Haven't tried it on anything else. I'm using .Net 2.0.


I think the problem is that Dns.GetHostEntry does a reverse lookup and Dns.GetHostByAddress doesn't.

Try other ip address / hostnames and you will see that sometimes it works.

I don't know of any solution, but maybe there is. You can stick with the obsolete function until you found a solution.

0

精彩评论

暂无评论...
验证码 换一张
取 消