Read http://www.delphigroups.info/2/7/199566.html about BoundIP.
You cannot make TCPClient into scrolling list of ips. If you could - there would be a array-like property where you could put 10 or 100 of addresses, not as little as only two.
What you really have to do - is actually try to connect to different address
Example:
function TryToConnect(const server: string): boolean; overload;
begin
try
IdTCPClient1.ReuseSocket := rsTrue;
IdTCPClient1.Host := server;
IdTCPClient1.Port := 5000;
IdTCPClient1.Connect;
Result := true;
except on E: Exception do begin
Result := false;
LogToFileAndScreenAnError(E.ClassName + ' ==> ' + E.Message);
end;
end;
function TryToConnect(const servers: array of string): boolean; overload;
var i: integer;
begin
Result := false;
for i := Low(servers) to High(Servers) do begin
Result := TryToConnect( servers[i] );
if Result then break;
end;
if not Result then LogAndShowError('Could not connect to any of servers! Read log file!');
{ or maybe even
if not Result then raise Exception.Create('Could not connect to any of servers! Read log file!');
}
end;
var ss: TStringDynArray;
SetLength(SS, 2);
ss[0] := 'localhost';
ss[1] := '192.168.3.10';
Success := TryToConnect(ss);