Java
Java
DNS Lookup
Do a DNS lookup to resolve a hostname to an IP address.Chilkat Java Downloads
import com.chilkatsoft.*;
public class ChilkatExample {
static {
try {
System.loadLibrary("chilkat");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load.\n" + e);
System.exit(1);
}
}
public static void main(String argv[])
{
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkSocket socket = new CkSocket();
int maxWaitMs = 10000;
String ipAddr = socket.dnsLookup("www.chilkatsoft.com",maxWaitMs);
if (socket.get_LastMethodSuccess() != true) {
System.out.println(socket.lastErrorText());
return;
}
System.out.println("IP Address: " + ipAddr);
}
}