Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Indy IdDayTime and syncronization 1

Status
Not open for further replies.

gcaramia

Programmer
Oct 30, 2003
185
IT
Hello

I want syncronize pc-clock every 6 hours.
Can somebody help me in using Indy IdDayTime Component or something else?

thanks
Giovanni Caramia
 
1) Drop a TTimer on your form and set its Interval property to 21600000 (6 hours = 360 minutes = 21600 seconds = 21600000 milliseconds)
2) Drop a TIdDayTime on your form and set its Host property to the server from which you will be retrieving (e.g. time.nist.gov). You also need to set its Port property to the port number you will be using to make the connection.
3) In the OnTimer event of the TTimer you need something like the following code. I have been unable to test this due to network restrictions at work but I imagine it's something like this:
Code:
IdDayTime1.Connect;
Label1.Caption := IdDayTime1.DayTimeStr;
IdDayTime1.Disconnect;
or this:
Code:
Label1.Caption := IdDayTime1.DayTimeStr;


Clive [infinity]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"To err is human, but to really foul things up you need a computer."
Paul Ehrlich
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To get the best answers from this forum see: faq102-5096
 
Thanks Clive
I solved syncronization with TIdTime component.
Code:
procedure TForm1.Button1Click(Sender: TObject);
begin
  IdTime1.Host := 'time.nist.gov';
  try
    IdTime1.SyncTime ;
  finally
    IdTime1.Disconnect;
  end;
end;

For anyone interested i post this link for a lot of public NTP servers.

Thanks again
Giovanni Caramia
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top