I am trying to ping a IP address, and I am using the following code:
It returns the following:
PING 192.168.0.10 (192.168.0.10) 56(84) bytes of data. --- 192.168.0.10 ping statistics --- 1 packets transmitted, 0 received, 100% packet loss, time 0ms
Doesn't the reply mean that it couldn't ping the IP?
It seems to transmit 1 packet since I think that my ping command is telling it to only send 1 packet, but there was 100% packet loss.
The IP address it's trying to Ping is my computers IP.
I then did a search and come across NJDude's sample:
https://www.b4x.com/android/forum/attachments/ping_sample-zip.17235/
But that is doing the same thing where it replies with 100% packet loss.
When using the ping sample from NJDude, I used:
That code above says it was able to ping the IP address.
If I then change the IP to something else that is not a IP address on my network like 192.168.4.10 it still says the host is online.
But when I change it to:
(with the correct IP)
It always returns the same result:
PING 192.168.0.10 (192.168.0.10) 56(84) bytes of data. --- 192.168.0.10 ping statistics --- 1 packets transmitted, 0 received, 100% packet loss, time 0ms
Is there something I am doing wrong ?
B4X:
Dim p As Phone
Dim sb As StringBuilder
sb.Initialize
p.Shell("ping -c 1 192.168.0.10",Null,sb,Null)
Log(sb)
It returns the following:
PING 192.168.0.10 (192.168.0.10) 56(84) bytes of data. --- 192.168.0.10 ping statistics --- 1 packets transmitted, 0 received, 100% packet loss, time 0ms
Doesn't the reply mean that it couldn't ping the IP?
It seems to transmit 1 packet since I think that my ping command is telling it to only send 1 packet, but there was 100% packet loss.
The IP address it's trying to Ping is my computers IP.
I then did a search and come across NJDude's sample:
https://www.b4x.com/android/forum/attachments/ping_sample-zip.17235/
But that is doing the same thing where it replies with 100% packet loss.
When using the ping sample from NJDude, I used:
B4X:
Sub Activity_Create(FirstTime As Boolean)
Msgbox(Ping("192.168.0.10", "Status", 5, 10, True), "PING Results")
End Sub
Sub Ping(URL As String, ResultsType As String, Attempts As Int, Timeout As Int, Message As Boolean) As String
Dim sb As StringBuilder
Dim p As Phone
sb.Initialize
If Message Then
ProgressDialogShow("Pinging " & URL)
DoEvents
DoEvents
End If
If ResultsType = "Report" Then Option = "-v "
If ResultsType = "Summary" OR ResultsType = "Status" Then Option = "-q "
p.Shell("ping -c" & Attempts & " -W" & Timeout & Option & URL, Null, sb, Null)
ProgressDialogHide
If sb.Length = 0 Then Return "Host unreachable"
If ResultsType = "Status" Then
Return "Host online"
Else
Return sb.ToString
End If
End Sub
That code above says it was able to ping the IP address.
If I then change the IP to something else that is not a IP address on my network like 192.168.4.10 it still says the host is online.
But when I change it to:
(with the correct IP)
B4X:
Sub Activity_Create(FirstTime As Boolean)
Msgbox(Ping("192.168.0.10", "Report", 5, 10, True), "PING Results") ' or when I use Summery instead of Report
End Sub
It always returns the same result:
PING 192.168.0.10 (192.168.0.10) 56(84) bytes of data. --- 192.168.0.10 ping statistics --- 1 packets transmitted, 0 received, 100% packet loss, time 0ms
Is there something I am doing wrong ?
Last edited: