Sample code for 30+ languages & platforms
PureBasic

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 PureBasic Downloads

PureBasic
IncludeFile "CkSocket.pb"

Procedure ChilkatExample()

    socket.i = CkSocket::ckCreate()
    If socket.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    ;  Start (or restart) the object's convenience timer.
    CkSocket::ckStartTiming(socket)

    ;  Perform some work.  (Here the thread simply sleeps to let time pass.)
    CkSocket::ckSleepMs(socket,1500)

    ;  Read the whole number of seconds elapsed since StartTiming was called.
    Debug "Elapsed seconds: " + Str(CkSocket::ckElapsedSeconds(socket))


    CkSocket::ckDispose(socket)


    ProcedureReturn
EndProcedure