home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 27 / CDROM27.iso / share / wnt / nettime / readme.txt next >
Encoding:
Text File  |  1998-09-03  |  8.1 KB  |  255 lines

  1. SwissTime for Delphi Version 1.01
  2. Copyright by Michael Gasser 1998
  3. ----------------------------------------------------------------------- 
  4.  
  5.  
  6. Disclaimer of Warranty 
  7.  
  8. THIS SOFTWARE AND THE ACCOMPANYING FILES ARE SOLD "AS IS" AND 
  9. WITHOUT WARRANTIES AS TO PERFORMANCE OR MERCHANTABILITY OR ANY 
  10. OTHER WARRANTIES WHETHER EXPRESSED OR IMPLIED. 
  11.  
  12. The user must assume the entire risk of using the program. 
  13.  
  14. ANY LIABILITY OF THE SELLER WILL BE LIMITED EXCLUSIVELY TO 
  15. PRODUCT REPLACEMENT OR REFUND OF PURCHASE PRICE. 
  16.   
  17. -----------------------------------------------------------------------   
  18.  
  19.  
  20.   
  21. The unit swisstime is used for getting the time from (daytime) timeservers as stated in RFC867 (TTime13, port 13, local
  22. time), RFC868 ( TTime37, UTC) , RFC2030 ( SNTPClient , UTC, see the SNTP40.html document in this ZIP file ). 
  23.  
  24. Similar components for RFC867,RFC868 are distributed with C++Builder 3 and Delphi 4 (??), but there is no SNTPClient
  25. (the best of the three ways to get the time from the internet) distributed with it! 
  26.  
  27. Before connecting to a timeserver, you have to set the HostAddr (for example bernina.ethz.ch), the
  28. HostPort (if you don't use the default port) and the timeout property and at least, you have to handle the event 
  29. OnDataAvailable : TDataAvailable. 
  30.  
  31. ----------------------------------------------------------------------- 
  32.  
  33. Source code 
  34.   
  35.  
  36. SwissTime.dcu is freeware. If you need the source code, you can get it by sending US$10 to 
  37. Michael Gasser, Quellenweg 3, CH-3084 Wabern. 
  38.  
  39. Thank you very much. 
  40. Delivery of the source code only by eMail. 
  41.  
  42. Contact : theiler.gasser@bluewin.ch 
  43.  
  44. ----------------------------------------------------------------------- 
  45.  
  46. Example 
  47. ... 
  48. ... 
  49. ... 
  50. with Time131 do 
  51. begin 
  52.         HostAddr := 'bernina.ethz.ch'; 
  53.         Timeout   := 300;   
  54.     // if you don't specify a port, the components default port will be set as HostPort. 
  55.  
  56.         connect; 
  57. end; 
  58. ... 
  59. ... 
  60. ... 
  61.  
  62. procedure TForm1.Time131DataAvailable(Sender: TObject; Error: Word); 
  63. begin 
  64.         Showmessage( datetostr( time131.datetime) + ', '+ timetostr( time131.datetime) ); 
  65. end; 
  66. ... 
  67. ... 
  68.  
  69. ----------------------------------------------------------------------- 
  70.  
  71. The other events : 
  72.  
  73. property  OnWinsockError              : TWinsockError 
  74. (type  TWinsockError              = procedure ( Sender: TObject; Error: word ) of object;) 
  75.  
  76.     Windows Socket Error. Error : Windows Socket Error code. 
  77.   
  78.   
  79.  
  80. property  OnTimeout                    : TNotifyEvent 
  81.   
  82.  
  83. property  OnReceiveError               : TNotifyEvent 
  84.     The component did not receive the correct number of bytes. 
  85.   
  86.  
  87. property  OnFormatError             : TNotifyEvent 
  88.     TTime13 component only : Unknown format. 
  89.   
  90.  
  91. property  OnResolveError            : TNotifyEvent 
  92.     "Can't resolve host."  Host with address HostAddr does probably not exist. 
  93.   
  94.   
  95. -----------------------------------------------------------------------  
  96.   
  97.  
  98. TTime37 
  99.  
  100. type 
  101.   TTime37 = class( TComponent ) 
  102.  
  103.   public 
  104.       procedure Connect; 
  105.       property  DateTime      : TDateTime        // DateTime sent by the server 
  106.       property  AdjTime       : TDateTime        // Adjusted DateTime (AdjTime := DateTime + Ping/2) 
  107.       property  Ping          : integer 
  108.       property  LocalIP       : string 
  109.       property  HostIP        : string 
  110.       property  P37Msg        : Integer          // RFC868 message 
  111.   
  112.  
  113.   published 
  114.     { Published-Deklarationen } 
  115.  
  116.     property  HostAddr        : String 
  117.     property  HostPort        : String 
  118.     property  Timeout         : integer 
  119.  
  120.     property  OnWinsockError  : TWinsockError 
  121.     property  OnDataAvailable : TDataAvailable 
  122.     property  OnTimeout       : TNotifyEvent 
  123.     property  OnReceiveError  : TNotifyEvent 
  124.     property  OnResolveError  : TNotifyEvent 
  125.   end; 
  126.  
  127. ----------------------------------------------------------------------- 
  128.  
  129. TTime13 
  130.   
  131.  
  132. type 
  133.   TTime13 = class( TComponent ) 
  134.  
  135.   public 
  136.     { Public-Deklarationen } 
  137.  
  138.       procedure Connect; 
  139.       property  NormTimeStr   : String              // There is a problem, using RFC867. 
  140.                             // The message from the time server
  141.                             // (TimeStr) is not normed. 
  142.                                                     // TTime13 norms the TimeStr received from the server. 
  143.                                                     //  Format : YYYY/MM/DD,hh:mm:ss 
  144.   
  145.       property  TimeStr       : String              // Message received from the timeserver. 
  146.  
  147.       property  DateTime      : TDateTime           // Date and Time
  148.       property  AdjTime       : TDateTime         // DateTime + Ping/2
  149.       property  Ping          : integer 
  150.       property  LocalIP       : string 
  151.       property  HostIP        : string 
  152.   
  153.  
  154.   published 
  155.     { Published-Deklarationen } 
  156.  
  157.     property  HostAddr        : String 
  158.     property  HostPort        : String 
  159.     property  Timeout         : integer 
  160.  
  161.     property  OnWinsockError  : TWinsockError 
  162.     property  OnDataAvailable : TDataAvailable 
  163.     property  OnTimeout       : TNotifyEvent 
  164.     property  OnReceiveError  : TNotifyEvent 
  165.     property  OnFormatError   : TNotifyEvent 
  166.     property  OnResolveError  : TNotifyEvent 
  167.   end; 
  168.  
  169. ----------------------------------------------------------------------- 
  170.  
  171.  
  172. SNTPClient 
  173.  
  174. type Fourbytes = record 
  175.       case integer of 
  176.         0: ( b : array[1..4] of byte); 
  177.         1: ( i : integer); 
  178.       end; 
  179.   
  180.  
  181. type NTP_Time  = record 
  182.           seconds  : Fourbytes; 
  183.           fraction : Fourbytes; 
  184.      end; 
  185.   
  186.  
  187. type SNTPMsgFormat = record 
  188.        Info            : Fourbytes; 
  189.        root_delay      : Fourbytes; 
  190.        root_dispersion : Fourbytes; 
  191.        reference_id    : Fourbytes; 
  192.  
  193.        ref_timestamp   : ntp_time; 
  194.        orig_timestamp  : ntp_time; 
  195.        rec_timestamp   : ntp_time; 
  196.        trans_timestamp : ntp_time; 
  197.      end; 
  198.  
  199. type  TSNTPError        = procedure (Sender: TObject; Error: word) of object; 
  200.   
  201.  
  202. type 
  203.   TSNTPClient = class(TComponent) 
  204.  
  205.   public 
  206.     { Public-Deklarationen } 
  207.  
  208.     function    DisregardMsg( Mess : SNTPMsgFormat ) : boolean;  // see \Info\SNTP40.txt
  209.     function    ntptimetodatetime ( t : ntp_time ) : TdateTime; 
  210.   
  211.     property    ServerIP       : string 
  212.     property    LocalIP        : string 
  213.  
  214.  
  215.     // Take a look at SNTP40.txt in the Info folder of this ZIP :
  216.     property    Leapindicator  : integer        // see \Info\SNTP40.txt
  217.     property    Version        : integer     // see \Info\SNTP40.txt
  218.     property    Mode           : integer     // see \Info\SNTP40.txt
  219.     property    Stratum        : integer     // see \Info\SNTP40.txt
  220.     property    Poll           : integer     // see \Info\SNTP40.txt
  221.     property    Precision      : integer     // see \Info\SNTP40.txt
  222.     property    Rootdelay      : double     // see \Info\SNTP40.txt
  223.     property    Rootdispersion : double     // see \Info\SNTP40.txt
  224.     property    Ref_time       : TDateTime     // see \Info\SNTP40.txt
  225.     property    Ori_time       : TDateTime     // see \Info\SNTP40.txt
  226.     property    Rec_time       : TDateTime     // see \Info\SNTP40.txt
  227.     property    Tra_time       : TDateTime     // see \Info\SNTP40.txt
  228.  
  229.     property    Disregard      : boolean         // You should disregard the message received by the server.
  230.     property    Ping           : integer 
  231.     property    SNTPMsg        : SNTPMsgFormat   // Message from the server
  232.  
  233.     property    DateTime       : TDateTime 
  234.     procedure   Connect; 
  235.     property    LocalPort      : String 
  236.     property    HostIP         : string 
  237.     property    AdjTime        : TDateTime     // AdjTime := DateiTime + Ping/2
  238.   
  239.  
  240.   published 
  241.     { Published-Deklarationen } 
  242.  
  243.     property    HostAddr       : String 
  244.     property    HostPort       : String 
  245.     property    Timeout        : integer 
  246.  
  247.     property    OnDataAvailable: TDataavailable 
  248.     property    OnTimeout      : TNotifyEvent 
  249.     property    OnWinsockError : TSNTPError 
  250.     property    OnResolveError : TNotifyEvent 
  251.     property    OnReceiveError : TNotifyEvent 
  252.   end; 
  253.   
  254. ----------------------------------------------------------------------- 
  255. END OF THIS FILE