1ntp_time(n)                 Network Time Facilities                ntp_time(n)
2
3
4
5______________________________________________________________________________
6

NAME

8       ntp_time - Tcl Time Service Client
9

SYNOPSIS

11       package require Tcl  8.0
12
13       package require time  ?1.2.1?
14
15       ::time::gettime ?options? timeserver ?port?
16
17       ::time::getsntp ?options? timeserver ?port?
18
19       ::time::configure ?options?
20
21       ::time::cget name
22
23       ::time::unixtime token
24
25       ::time::status token
26
27       ::time::error token
28
29       ::time::reset token ?reason?
30
31       ::time::wait token
32
33       ::time::cleanup token
34
35______________________________________________________________________________
36

DESCRIPTION

38       This  package  implements  a  client  for  the  RFC  868  TIME protocol
39       (http://www.rfc-editor.org/rfc/rfc868.txt) and also  a  minimal  client
40       for  the  RFC  2030  Simple  Network Time Protocol (http://www.rfc-edi
41       tor.org/rfc/rfc2030.txt).  RFC 868 returns the time in seconds since  1
42       January  1900  to  either  tcp or udp clients. RFC 2030 also gives this
43       time but also provides a fractional part which  is  not  used  in  this
44       client.
45

COMMANDS

47       ::time::gettime ?options? timeserver ?port?
48              Get the time from timeserver. You may specify any of the options
49              listed for the configure command here. This  command  returns  a
50              token  which  must  then  be used with the remaining commands in
51              this package. Once you have finished, you should use cleanup  to
52              release all resources. The default port is 37.
53
54       ::time::getsntp ?options? timeserver ?port?
55              Get  the time from an SNTP server. This accepts exactly the same
56              arguments as ::time::gettime except that  the  default  port  is
57              123.  The result is a token as per ::time::gettime and should be
58              handled in the same way.
59
60              Note that it is unlikely that any SNTP server will  reply  using
61              tcp  so  you will require the tcludp or the ceptcl package. If a
62              suitable package can be loaded then the  udp  protocol  will  be
63              used by default.
64
65       ::time::configure ?options?
66              Called  with  no  arguments this command returns all the current
67              configuration options and values. Otherwise it should be  called
68              with pairs of option name and value.
69
70              -protocol number
71                     Set the default network protocol. This defaults to udp if
72                     the tcludp package is available. Otherwise  it  will  use
73                     tcp.
74
75              -port number
76                     Set  the  default  port to use. RFC 868 uses port 37, RFC
77                     2030 uses port 123.
78
79              -timeout number
80                     Set  the  default  timeout  value  in  milliseconds.  The
81                     default is 10 seconds.
82
83              -command number
84                     Set  a  command  procedure  to  be  run  when  a reply is
85                     received. The procedure is called  with  the  time  token
86                     appended to the argument list.
87
88              -loglevel number
89                     Set the logging level. The default is 'warning'.
90
91       ::time::cget name
92              Get the current value for the named configuration option.
93
94       ::time::unixtime token
95              Format  the  returned  time  for  the  unix  epoch. RFC 868 time
96              defines time 0 as 1 Jan 1900, while unix time defines time 0  as
97              1 Jan 1970. This command converts the reply to unix time.
98
99       ::time::status token
100              Returns the status flag. For a successfully completed query this
101              will  be  ok.  May  be  error  or  timeout  or  eof.   See  also
102              ::time::error
103
104       ::time::error token
105              Returns  the error message provided for requests whose status is
106              error.  If there is no error message then  an  empty  string  is
107              returned.
108
109       ::time::reset token ?reason?
110              Reset  or  cancel  the  query optionally specfying the reason to
111              record for the error command.
112
113       ::time::wait token
114              Wait for a query to complete and return the status upon  comple‐
115              tion.
116
117       ::time::cleanup token
118              Remove all state variables associated with the request.
119
120              % set tok [::time::gettime ntp2a.mcc.ac.uk]
121              % set t [::time::unixtime $tok]
122              % ::time::cleanup $tok
123
124
125
126              % set tok [::time::getsntp pool.ntp.org]
127              % set t [::time::unixtime $tok]
128              % ::time::cleanup $tok
129
130
131
132              proc on_time {token} {
133                 if {[time::status $token] eq "ok"} {
134                    puts [clock format [time::unixtime $token]]
135                 } else {
136                    puts [time::error $token]
137                 }
138                 time::cleanup $token
139              }
140              time::getsntp -command on_time pool.ntp.org
141
142

AUTHORS

144       Pat Thoyts
145

BUGS, IDEAS, FEEDBACK

147       This  document,  and the package it describes, will undoubtedly contain
148       bugs and other problems.  Please report such in the category ntp of the
149       Tcllib  Trackers  [http://core.tcl.tk/tcllib/reportlist].   Please also
150       report any ideas for enhancements  you  may  have  for  either  package
151       and/or documentation.
152
153       When proposing code changes, please provide unified diffs, i.e the out‐
154       put of diff -u.
155
156       Note further that  attachments  are  strongly  preferred  over  inlined
157       patches.  Attachments  can  be  made  by  going to the Edit form of the
158       ticket immediately after its creation, and  then  using  the  left-most
159       button in the secondary navigation bar.
160

SEE ALSO

162       ntp
163

KEYWORDS

165       NTP, SNTP, rfc 2030, rfc 868, time
166

CATEGORY

168       Networking
169
171       Copyright (c) 2002, Pat Thoyts <patthoyts@users.sourceforge.net>
172
173
174
175
176tcllib                               1.2.1                         ntp_time(n)
Impressum