문제

Could some one show me how I can make a DNS request to a particular DNS server and get the response as well as the response time?

I intend to use this in an signed applet. Is this allowed in an applet?

도움이 되었습니까?

해결책

The standard Java API's you can use is:

java.net.InetAddress

Or the more advanced JNDI lookup API:

DNS Service Provider for the Java Naming Directory Interface

Both above Java API's will work in an signed applet if the applet is granted the required policy rights (java.net.SocketPermission for example). But when the applet is used on a web page, the user will first be shown a dialog that asks for permission to run. To measure performance of these API calls, one can of course use a simple call to java.lang.Systen.currentTimeMillis()

I do not recommend using dnsjava.org, it used to be popular, but the project has not been updated since 2004.

다른 팁

Just call one of the InetAddress methods, or else have a look at JNDI with the DNS provider.

You need a Java implementation of DNS, such as dnsjava (see examples.html). It's certainly not possible to use this in an applet, as it violates the networking restrictions.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top