comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Get time and date from a server using a socket
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Get time and date from a server using a socket [message #65343 is a reply to message #65340] Fri, 27 February 2009 01:19 Go to previous messageGo to previous message
Allan Whiteford is currently offline  Allan Whiteford
Messages: 117
Registered: June 2006
Senior Member
bernat wrote:
> Thanks Allan,
>
> Ok, I can reject NTP to get the time from external server.
> That's true that maybe is the firewall who blocks the communication
> but I think that my code (read a simple string on port 13) should
> works. The IDL help, shows this same example and I wanna find my
> purpose
>
> More suggestions ?
>
>

The following works for me:

IDL> socket, lun, 'time-a.nist.gov', 13, /get_lun
IDL> mystring=''
IDL> readf, lun, mystring
IDL> readf, lun, mystring
IDL> free_lun, lun
IDL> print, mystring
54889 09-02-27 08:52:23 00 0 0 807.6 UTC(NIST) *

Note that this timeserver seems to first return a blank line and then on
the next line it returns the actual time. I don't know if daytime is
supposed to do this or not. Maybe that is what was causing you a problem.

For port 37, I guess the way to go is something like this:

IDL> socket, lun, 'time-a.nist.gov', 37, /get_lun,/swap_endian
IDL> data=0ul
IDL> readu, lun, data
IDL> free_lun, lun
IDL> print, data
3444714975
IDL> print, data / 60 / 60 / 24 / 365.26
109.152

where data is the number of seconds since 1/1/1900. The 109 and a
wee-bit years seems sensible. YMMV with the need to use /swap_endian.

Maye there is a function to do the (non-trivial) conversion for you in
IDL, I'm not sure - it's certainly not a case of just assuming there are
365.26 days in a year (which may not even be true).

Thanks,

Allan
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Fractions in IDL
Next Topic: Get time and date from a server using a socket

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 20:02:54 PDT 2025

Total time taken to generate the page: 0.32283 seconds