用iimer控件
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Timer1.Interval:=3000; //定时器,3秒钟间隔
Timer1.Enabled:=False;
if ClientSocket.Active then ClientSocket.Active := False;
if Length(Server) > 0 then
with ClientSocket do
begin
Host := Server;
Active := True;
end;
Timer1.Enabled:=True;
end;