Java
Chilkat2 Java
DNS Lookup
Do a DNS lookup to resolve a hostname to an IP address.Chilkat Java Downloads
import com.chilkatsoft.chilkat2.ChilkatException;
import com.chilkatsoft.chilkat2.Socket;
public class ChilkatExample {
public static void main(String[] args) {
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
Socket socket = new Socket();
int maxWaitMs = 10000;
String ipAddr;
try {
ipAddr = socket.dnsLookup("www.chilkatsoft.com", maxWaitMs);
} catch (ChilkatException e) {
System.out.println(e.getLastErrorText());
return;
}
System.out.println("IP Address: " + ipAddr);
}
}