|
-
Aug 9th, 2006, 10:21 AM
#1
Thread Starter
New Member
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 
-
Aug 9th, 2006, 12:15 PM
#2
Frenzied Member
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
-
Aug 9th, 2006, 12:21 PM
#3
Thread Starter
New Member
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 
-
Aug 9th, 2006, 12:47 PM
#4
Frenzied Member
Re: Time Synchronization
Hi
if the PC as Internet Access try
VB Code:
Private Function SyncClockViaInternet() As Boolean
Dim iret As Integer
Dim rBuff(1023) As Byte
Dim sBuff As String
Dim tBuff() As String
Dim nDate As Date
Dim clientSocket As Socket
Dim d As Date
Try
clientSocket = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
clientSocket.Connect(New IPEndPoint(Dns.Resolve("time.nist.gov").AddressList(0), 13))
iret = clientSocket.Receive(rBuff)
sBuff = Encoding.ASCII.GetString(rBuff, 0, iret - 1)
'format: 53865 06-05-10 15:16:44 50 0 0 253.9 UTC(NIST) *
sBuff = Replace(sBuff, Chr(10), "")
tBuff = Split(sBuff, " ")
nDate = "20" & Replace(tBuff(1), "-", "/") & " " & tBuff(2)
d = "#" & Format(TimeZone.CurrentTimeZone.ToLocalTime(nDate), "MM/dd/yyyy") & " " & Format(TimeZone.CurrentTimeZone.ToLocalTime(nDate), "HH:mm:ss") & "#"
OpenNETCF.Win32.DateTimeEx.SetLocalTime(d)
clientSocket.Close()
Return True
Catch ex As Exception
Try
clientSocket.Close()
Catch
End Try
Return False
End Try
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|