开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜