Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: How do I check if a datasnap server is reachable/down from Android


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 1 - Last Post: Aug 11, 2015 11:43 PM Last Post By: Robert Björkman
Michael Eriksen

Posts: 14
Registered: 6/29/15
How do I check if a datasnap server is reachable/down from Android  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 15, 2015 1:20 AM
Hey all,
I hope that someone can help me.

My problem is that I need to check if a server with a specific IP address is down for an app to Android.
I have tried to ping the server - but no matter what - I always get the error "socket error #1". And it's because the routine don't have admin/root access to Android.

So what do I do? I have googlet without success.
I really hope that someone can help me with a little codesnippet.

I'm using Delphi XE8

Thanks in advance,
Michael

Edited by: Michael Eriksen on Jun 15, 2015 4:07 AM

Edited by: Michael Eriksen on Jun 15, 2015 5:30 AM
Robert Björkman

Posts: 7
Registered: 10/1/11
Re: How do I check if a datasnap server is reachable/down from Android  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 11, 2015 11:43 PM   in response to: Michael Eriksen in response to: Michael Eriksen
Michael Eriksen wrote:
Hey all,
I hope that someone can help me.

My problem is that I need to check if a server with a specific IP address is down for an app to Android.
I have tried to ping the server - but no matter what - I always get the error "socket error #1". And it's because the routine don't have admin/root access to Android.

So what do I do? I have googlet without success.
I really hope that someone can help me with a little codesnippet.

I'm using Delphi XE8

Thanks in advance,
Michael

Edited by: Michael Eriksen on Jun 15, 2015 4:07 AM

Edited by: Michael Eriksen on Jun 15, 2015 5:30 AM

I use something like this:

function TestConnection( const AHostName : string; const APort : integer ) : boolean;
var
tcp : TIdTCPClient;
exists : boolean;
i : integer;
begin

result := false;
tcp := TIdTCPClient.Create(nil);
try
tcp.Host := AHostname;
tcp.Port := APort;
tcp.ReadTimeout := 3000;
tcp.ConnectTimeout := 3000;
i := 0;
while ( i < 3 ) do
begin
Inc(i);
try
tcp.Connect;
tcp.Disconnect;
exit(true); //Success
except on e : Exception do
FGetLastError := 'Connect tcp error :' + e.Message;
end;
end;
finally
tcp.free;
end;

end;

Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02