Home > Back-end >  Indy10 TIdTimeUDP and TIdTimeUDPServer cannot communicate
Indy10 TIdTimeUDP and TIdTimeUDPServer cannot communicate

Time:10-17

Use TIdTimeUDP and TIdTimeUDPServer synchronous computer time, found that the two cannot communicate, TIdTimeUDP use SyncTime method have been False, and directly read time IdTimeUDP. Datetime has always been in 1889,
Version: Delphi2010 + Indy10.5.5
 procedure Tserver. FormCreate (Sender: TObject); 
The begin
IdTimeUDPServer1. DefaultPort:=12345;
Try
IdTimeUDPServer1. Active:=True;
Except,
ShowMessage (' not ');
end;

Memo1. The Clear;
end;
Client:
Procedure TClientForm. Button1Click (Sender: TObject);
The begin
If IdTimeUDP1. Active then
IdTimeUDP1. Active:=False;

IdTimeUDP1. Host:=Edit1. Text;
IdTimeUDP1. Port:=12345;
//IdTimeUDP1. BoundIP:='127.0.0.1;
//IdTimeUDP1. BoundPort:=12344;
IdTimeUDP1. Active:=True;
IdTimeUDP1. OpenProxy;

If IdTimeUDP1. SyncTime then//don't use this one, return to 1899
Edit2. Text:=DateTimeToStr (IdTimeUDP1. DateTime)
The else
Edit2. Text:='error';
end;

Procedure TClientForm. FormShow (Sender: TObject);
The begin
Edit1. Text:='127.0.0.1;
Edit2. Text:=' ';
Memo1. The Clear;
end;
such simple code, the same computer or two computers test is not successful,
If using TIdTime and TIDTimeServer, very normal,
Don't know what's the problem, and then use the D7 + Indy9 test in the same computer, or this code, but very successful, find on the Internet for a long time, don't know why?
Please give directions,

CodePudding user response:

Used 10, lu had onlookers
  • Related