Sample code for 30+ languages & platforms
Java

Measure Elapsed Time with the Convenience Timer

See more Socket/SSL/TLS Examples

Demonstrates Socket.StartTiming, which starts or restarts the object's convenience timer. The ElapsedSeconds property then reports the whole number of seconds since the call.

Background. This timer is a convenience for measuring durations and does not affect connection behavior or timeouts.

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();

    //  Start (or restart) the object's convenience timer.
    socket.StartTiming();

    //  Perform some work.  (Here the thread simply sleeps to let time pass.)
    socket.SleepMs(1500);

    //  Read the whole number of seconds elapsed since StartTiming was called.
    System.out.println("Elapsed seconds: " + socket.get_ElapsedSeconds());
  }
}