i have this code to check connection to my server so code is like this:
function CheckInternet(ssip:string): boolean;
begin
result:=false;
with form1.IdTCPClient1 do
try
ReadTimeout:=2000;
ConnectTimeout:=1000;
Port:=80;
Host:=ssip;
Connect;
Disconnect;
result:=true;
except
on E:EIdSocketError do
result:=false;
end;
end;
after running: if server is online every thing is ok but if server is online i got a lot of this error:
there is not difference in debug
or release
mode! both have error
also in android this cause two app crash and dont handling remain code!!..
how can i avoid this error?
What you see can happen only if you are calling
CheckInternet()
in a loop in the main UI thread and not catching raised exceptions. The popup messages are being displayed by a default exception handler within FMX when it catches an uncaught exception.EIdSocketError
is not the only type of exception thatConnect()
can raise. There are several other possible types, which you are not catching. You should remove the filter from yourexcept
block: