On Tuesday, 30 August 2011, DialToneApps <[email protected]> wrote:
> Correction: InetAddress.isReachable() does not 'send the ICMP ECHO'.

>From the API docs of InetAddress:

"public boolean isReachable (int timeout)

Tries to reach thisInetAddress. This method first tries to use ICMP (ICMP
ECHO REQUEST). When first step fails, a TCP connection on port 7 (Echo) of
the remote host is established."

> It tries to work around the Android/Java limitation of not being able
> to craft and send an ICMP packet by
> 1) Sending a tcp connect on the echo port (port 7)
> 2) Recognizing a response (any response whether a successful connect
> OR a reset) as an indication that the destination exists
> At best this is a hack. Port 7 is generally not allowed by firewalls
> and therefore this method rarely works for hosts outside your own
> subnet. The only way (as far as i know) to 'ping' in non-rooted
> standard-issue Android is by using the command-line 'ping' utility.
> I would love to know other ways of pinging if anyone else knows.

Telneting to a set of known ports perhaps?

>
> On Aug 24, 10:59 am, Daniel Drozdzewski <[email protected]>
> wrote:
>> On 18 August 2011 20:39, Luiz Carvalho <[email protected]> wrote:
>>
>> > Hello Guys
>>
>> > I've got a problem.
>> > I can't run ping on emulator, even rooted, only in my Galaxy 5.
>>
>> > Using this procedure:
>>
>> >             proc = Runtime.getRuntime (). exec ("su");
>> >             DataProc = new DataOutputStream
>> >             DataOutputStream (proc.getOutputStream ());
>> >             dataProc.writeBytes ("exec pingwww.google.com-c2 \ n");
>>
>> > I get the response in the device, but in the emulator  no have
>> > answers.
>>
>> > I need of the statistics generated by ping.
>>
>> > Can anyone help me?
>>
>> Is there some spacing issue in your command line: "-c 2" ?
>>
>> There is much better solution:
>>
>> use InetAddress.isreachable(). It does send the ICMP ECHO (i.e. ping).
>>
>> You can get your stats by timing this call (or multiple calls).
>>
>> --
>> Daniel Drozdzewski
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en

-- 
Daniel Drozdzewski

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to