Get SNTP Server Time and Set LocalTime

Get SNTP Server Time and Set LocalTime

Postby ssbbs » Fri Oct 13, 2006 2:01 pm

The Library is compile use BCC5 for xHarbour and Fivewin(free).

link:http://www4.zzz.com.tw/phpbb2/viewtopic.php?t=29

Code: Select all  Expand view
Func    Test()
Local   aNet      := {},;
        nPort     := 123,;
        cIp       := "time.windows.com",;
        lSync     := .T.,;
        oSntp     := NIL

        ? "test begin"

        // test-1
        // lSync = .T., Set LocalTime same as NTP Server time
         oSntp := TSntp():New( cIP, nPort, lSync )
        // or oSntp := TSntp():New(); oSntp:cIp := '....'; oSntp:nPort = ....
        If oSntp:GetData()
           ? oSntp:Date(), "date"
           ? oSntp:Time(), "time"
           ? oSntp:nWeek, "Week"
           ? oSntp:nDayOfYear, "Day Of Year"
        Else
           ? "Fail"
        EndIf

        // test-2
        If oSntp:GetData()
           ? oSntp:Date(), "date"
           ? oSntp:Time(), "time"
        Else
           ? "Fail"
        EndIf

        ? "test end"

Return  NIL

User avatar
ssbbs
 
Posts: 104
Joined: Mon Oct 17, 2005 3:03 am
Location: Taiwan

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 64 guests