Results 1 to 4 of 4

Thread: Time Synchronization

  1. #1

    Thread Starter
    New Member facial^'s Avatar
    Join Date
    Jun 2006
    Location
    Orange TX
    Posts
    14

    Time Synchronization

    I’m using Microsoft Mobile on an iPaq handheld computer. What I would like to be able to do is sync the time of a server with the handheld.

    I receive information from a server and then do some work and send it back to the server. If the time on the handheld is different from the server time, I can’t see any reports of the work (edited fields) that I did. The application does time stamp, but it only stamps with the current time of the handheld and not the server. This is why I would like to come up with a script of some kind to sync time with the handheld and server.
    to each his own....

    dont trust North Korea

  2. #2
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: Time Synchronization

    How do you connect?
    If it is activesync, there is an option to sync the PPC time with the PC when you connect?

    Are you using SqlClient - use the GetDate() function and then set the time that way - when we open a remote database, we set the time on the PPC.

    There are several ways of doing it - depends on your app and connection

    Pete

  3. #3

    Thread Starter
    New Member facial^'s Avatar
    Join Date
    Jun 2006
    Location
    Orange TX
    Posts
    14

    Re: Time Synchronization

    Connection is wireless. So when the handheld (connects)pings the server ip, I would like it to update. I do not have access to do anything to the database that the handheld is connecting too so I was hopeing there is another way. Thanks for your reply.
    to each his own....

    dont trust North Korea

  4. #4
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: Time Synchronization

    Hi
    if the PC as Internet Access try
    VB Code:
    1. Private Function SyncClockViaInternet() As Boolean
    2.         Dim iret As Integer
    3.         Dim rBuff(1023) As Byte
    4.         Dim sBuff As String
    5.         Dim tBuff() As String
    6.         Dim nDate As Date
    7.         Dim clientSocket As Socket
    8.         Dim d As Date
    9.  
    10.         Try
    11.             clientSocket = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
    12.             clientSocket.Connect(New IPEndPoint(Dns.Resolve("time.nist.gov").AddressList(0), 13))
    13.             iret = clientSocket.Receive(rBuff)
    14.             sBuff = Encoding.ASCII.GetString(rBuff, 0, iret - 1)
    15.             'format: 53865 06-05-10 15:16:44 50 0 0 253.9 UTC(NIST) *
    16.             sBuff = Replace(sBuff, Chr(10), "")
    17.             tBuff = Split(sBuff, " ")
    18.             nDate = "20" & Replace(tBuff(1), "-", "/") & " " & tBuff(2)
    19.             d = "#" & Format(TimeZone.CurrentTimeZone.ToLocalTime(nDate), "MM/dd/yyyy") & " " & Format(TimeZone.CurrentTimeZone.ToLocalTime(nDate), "HH:mm:ss") & "#"
    20.             OpenNETCF.Win32.DateTimeEx.SetLocalTime(d)
    21.             clientSocket.Close()
    22.             Return True
    23.         Catch ex As Exception
    24.             Try
    25.                  clientSocket.Close()
    26.             Catch
    27.             End Try
    28.             Return False
    29.         End Try
    30.     End Function

    Pete

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width