In our Application we offer connect to our server by in 2 ways - by URL (when we are in LTE network) or direct by IP (when we are in same WLAN network as the server).
The app tried to connect the URL first, an when not available (EIdSocketError occours) then we try to connect by direct IP address. On IOS this is working perfect.
On Android, the Indy 10 pop up with a Message Box 'Socket Error 107' when we try to connect to an URL which is not available yet.
We are not able to catch the exception in our code, so our app is not able to handle this.
How can we get the Socket Error 107 instead a popup to the user ??
Here are the relevant code segments. Thanks in advance.
The app tried to connect the URL first, an when not available (EIdSocketError occours) then we try to connect by direct IP address. On IOS this is working perfect.
On Android, the Indy 10 pop up with a Message Box 'Socket Error 107' when we try to connect to an URL which is not available yet.
We are not able to catch the exception in our code, so our app is not able to handle this.
How can we get the Socket Error 107 instead a popup to the user ??
Here are the relevant code segments. Thanks in advance.
Code:
private
{ Private declarations }
FClient: TIdTCPClient;
// -----------------------------------------------------------------------------
// Erzeugen
constructor TAppComThread.Create(OnMsgEvent: TComEvent);
begin
FClient := TIdTCPClient.Create(nil);
FClient.OnStatus := OnStatus;
FClient.OnConnected := OnConnected;
FClient.ConnectTimeout := c_TcpConnectTimeout;
FClient.ReadTimeout := c_TcpReadTimeout;
end;
//------------------------------------------------------------------------------
// Ausführen
procedure TAppComThread.Execute;
var
begin
while not Terminated do
begin
Sleep(10);
// Connect now
if bConnectFlag then
begin
bConnectFlag := false;
Try
FClient.Port := c_TcpPortPersonen;
FClient.Connect;
Except
On E: EIdSocketError Do
begin
bConnectionFailed := true;
ReplyMessage('167: No Socket at '+ FClient.Host);
end;
On E: Exception Do
begin
bConnectionFailed := true;
ReplyMessage('172: No Connection to '+ FClient.Host);
end;
End;
end;
end;
end;