ntp_time(3tcl) | Network Time Facilities | ntp_time(3tcl) |
ntp_time - Tcl Time Service Client
package require Tcl 8.0
package require time ?1.2.1?
::time::gettime ?options? timeserver ?port?
::time::getsntp ?options? timeserver ?port?
::time::configure ?options?
::time::cget name
::time::unixtime token
::time::status token
::time::error token
::time::reset token ?reason?
::time::wait token
::time::cleanup token
This package implements a client for the RFC 868 TIME protocol (http://www.rfc-editor.org/rfc/rfc868.txt) and also a minimal client for the RFC 2030 Simple Network Time Protocol (http://www.rfc-editor.org/rfc/rfc2030.txt). RFC 868 returns the time in seconds since 1 January 1900 to either tcp or udp clients. RFC 2030 also gives this time but also provides a fractional part which is not used in this client.
Note that it is unlikely that any SNTP server will reply using tcp so you will require the tcludp or the ceptcl package. If a suitable package can be loaded then the udp protocol will be used by default.
% set tok [::time::gettime ntp2a.mcc.ac.uk] % set t [::time::unixtime $tok] % ::time::cleanup $tok
% set tok [::time::getsntp pool.ntp.org] % set t [::time::unixtime $tok] % ::time::cleanup $tok
proc on_time {token} { if {[time::status $token] eq "ok"} { puts [clock format [time::unixtime $token]] } else { puts [time::error $token] } time::cleanup $token } time::getsntp -command on_time pool.ntp.org
Pat Thoyts
This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category ntp of the Tcllib Trackers [http://core.tcl.tk/tcllib/reportlist]. Please also report any ideas for enhancements you may have for either package and/or documentation.
When proposing code changes, please provide unified diffs, i.e the output of diff -u.
Note further that attachments are strongly preferred over inlined patches. Attachments can be made by going to the Edit form of the ticket immediately after its creation, and then using the left-most button in the secondary navigation bar.
ntp
NTP, SNTP, rfc 2030, rfc 868, time
Networking
Copyright (c) 2002, Pat Thoyts <patthoyts@users.sourceforge.net>
1.2.1 | tcllib |