looking for example code for time server
looking for example code for time server
Hi,
Iam looking for some example code for getting time from a time server using Hollywood, I have looked on the forum but have not found any.
Does some have an example of how to do this.
I have not done anything with networks and servers before, so I do not know where to start.
Cheers
Leo
Iam looking for some example code for getting time from a time server using Hollywood, I have looked on the forum but have not found any.
Does some have an example of how to do this.
I have not done anything with networks and servers before, so I do not know where to start.
Cheers
Leo
----------------------------------------------------------------------------------------
Redlion
Sam460 Lite
A4000 A3000 A2000 A1200 A1000 A600 A500 CD32
Redlion
Sam460 Lite
A4000 A3000 A2000 A1200 A1000 A600 A500 CD32
Re: looking for example code for time server
Hi All,
I have come up with a working example but it is not the recommended way.
It is recommended to use the Network Time Protocol (NTP) but I can not get that to work.
I will keep looking and trying.
Cheers
I have come up with a working example but it is not the recommended way.
Code: Select all
@DISPLAY {Hidden = true}
MUI.CreateGui([[
<?xml version="1.0" encoding="iso-8859-1"?>
<application base="DidL">
<window title=" Internet time" id="window" width="640" notify="closerequest" >
<vgroup background="pre_ShadowFill">
<vgroup>
<text id="timer"></text>
<Button id="Quit" notify="pressed" >Quit</Button>
</vgroup>
</vgroup>
</window>
</application>
]])
Function p_MUIEvent(id) ; * Joint event handler for MUI buttons and menus ***********************************
Switch id
Case "Quit":
End
EndSwitch
EndFunction
Function p_EventFunc(msg)
Switch msg.action
Case "MUIRoyale":
Switch msg.attribute
Case "CloseRequest":
End
Case "Pressed":
p_MUIEvent(msg.id)
Endswitch
Case "HideWindow":
MUI.Set("app", "iconified", True)
Case "ShowWindow":
MUI.Set("app", "iconified", False)
EndSwitch
EndFunction
; listen to these events!
InstallEventHandler({MUIRoyale = p_EventFunc, HideWindow = p_EventFunc, ShowWindow = p_EventFunc})
While Strlen(data$) =0
OpenConnection(1, "time.nist.gov", 13)
wait(25)
data$ = ReceiveData(1,#RECEIVEALL)
CloseConnection(1)
wend
mui.set("timer", "contents", data$)
; main loop!
Repeat
WaitEvent
Forever
I will keep looking and trying.
Cheers
----------------------------------------------------------------------------------------
Redlion
Sam460 Lite
A4000 A3000 A2000 A1200 A1000 A600 A500 CD32
Redlion
Sam460 Lite
A4000 A3000 A2000 A1200 A1000 A600 A500 CD32
Re: looking for example code for time server
@ Andreas
Hi Andreas, is there any chance that you could give me some example code using the
CreateUDPObject()
SendUDPData()
and
ReceiveUDPData()
I have tried and no combination seems to work, I do not know if it is the code or the server that is the problem. ( i am at work so I cant submit me code).
Thanks
Leo
Hi Andreas, is there any chance that you could give me some example code using the
CreateUDPObject()
SendUDPData()
and
ReceiveUDPData()
I have tried and no combination seems to work, I do not know if it is the code or the server that is the problem. ( i am at work so I cant submit me code).
Thanks
Leo
----------------------------------------------------------------------------------------
Redlion
Sam460 Lite
A4000 A3000 A2000 A1200 A1000 A600 A500 CD32
Redlion
Sam460 Lite
A4000 A3000 A2000 A1200 A1000 A600 A500 CD32
- airsoftsoftwair
- Posts: 5443
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
Re: looking for example code for time server
Unfortunately, I don't know anything about the NTP protocol so I can't help with NTP specifics. Here is some example code from my test files that shows you how to use the UDP functions
udpserver.hws
udpsender.hws:
First run udpserver.hws. Then run udpsender.hws. Whenever you press a key in udpsender.hws, it should then be received and printed by udpserver.hws.
udpserver.hws
Code: Select all
af = createudpobject(nil, 12345)
debugprint(getlocalport(af, #networkudp))
installeventhandler({onreceiveudpdata = function(msg)
debugprint(msg.action, receiveudpdata(af))
endfunction})
repeat
waitevent
forever
Code: Select all
createudpobject(1)
installeventhandler({onkeyup = function(msg)
sendudpdata(1, msg.key, "127.0.0.1", 12345)
endfunction})
repeat
waitevent
forever
Re: looking for example code for time server
Hello,
I test the example but if I do
it only works with 1 single character
I test the example but if I do
Code: Select all
sendudpdata (1, "Hello World", "127.0.0.1", 12345)
- airsoftsoftwair
- Posts: 5443
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
Re: looking for example code for time server
Can't reproduce this. "Hello World" works fine here too. What platform are you on?
Re: looking for example code for time server
i saw topic and willing to test a bit
tried the examples you have posted above as client-server tests
i found a problem
if test is as a single byte character arrives, but if the first character is NOT UTF compatible (raw data) compiler claims for utf error, or fails at all
i try with other tools (packetsender) to send data and as logn as a single character is above ByteChr(127) fails
tried the examples you have posted above as client-server tests
i found a problem
if test is as a single byte character arrives, but if the first character is NOT UTF compatible (raw data) compiler claims for utf error, or fails at all
i try with other tools (packetsender) to send data and as logn as a single character is above ByteChr(127) fails
Code: Select all
; Client example from above test files
createudpobject(1)
installeventhandler({onkeyup = function(msg)
sendudpdata(1, bytechr(65), "127.0.0.1", 12345) ; <- OK
sendudpdata(1, bytechr(128), "127.0.0.1", 12345) ; <-NOT OK
endfunction})
repeat
waitevent
forever
Christos
- airsoftsoftwair
- Posts: 5443
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
Re: looking for example code for time server
True, I can confirm that. I'll see what's wrong there.
Which function call returns this UTF error? SendUDPData() or a different function?plouf wrote: ↑Sat Oct 17, 2020 11:30 am i found a problem
if test is as a single byte character arrives, but if the first character is NOT UTF compatible (raw data) compiler claims for utf error, or fails at all
i try with other tools (packetsender) to send data and as logn as a single character is above ByteChr(127) fails