In my Android application, I have used the ping command with appropriate option mentioned in below link: http://linux.about.com/od/commands/l/blcmdl8_ping.htm
All other options are working except -W which is timeout.
I am using this command to ping with 5sec time out: ping 131.107.8.1 -W 5 I believe this should give "Request timed out" after 5sec. I also tested it with "Test Ping" application but it failed there as well.
Where as in my windows machine, I am using this command for same IP: ping 131.107.8.1 -w 7000 And it is properly giving "Request timed out" after 7000msec.
Any pointer where am I missing the concept?
I'm not entirely sure on Android's implementation of Ping, but on Linux the flags ping -w
and ping -W
have very different operations.
In this case, you're using ping -W
, which waits for a timeout to happen across the network. According to the man page:
-W timeout Time to wait for a response, in seconds. The option affects only timeout in absense of any responses, otherwise ping waits for two RTTs.
I believe what you're attempting to do is set a deadline for the Ping command, e.g. ping -w
as described by the man page again:
-w deadline Specify a timeout, in seconds, before ping exits regardless of how many packets have been sent or received. In this case ping does not stop after count packet are sent, it waits either for deadline expire or until count probes are answered or for some error notification from network.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With