Sample code for 30+ languages & platforms
Java

Clear the DNS Cache

See more Socket/SSL/TLS Examples

Demonstrates Socket.DnsCacheClear, which clears Chilkat's process-wide in-memory DNS cache so subsequent hostname resolutions perform a new lookup.

Background. The cache is shared by Chilkat objects in the process, so clearing it affects subsequent lookups across the application.

Chilkat Java Downloads

Java
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[])
  {
    CkSocket socket = new CkSocket();

    //  Clear Chilkat's process-wide in-memory DNS cache.  Subsequent hostname resolutions perform a new
    //  lookup as needed.  The cache is shared by Chilkat objects in the process.
    socket.DnsCacheClear();
    System.out.println("DNS cache cleared.");
  }
}