Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Private spPing As Ping
Private Button1 As Button
End Sub
Public Sub Initialize
B4XPages.GetManager.LogEvents = True
spPing.Initialize(Me, "SPPing")
spPing.Destination = "google.com"
spPing.Attempts = 4
spPing.Timeout = 200
End Sub
Private Sub SPPing_PingStarted
Log("Ping started")
End Sub
Private Sub SPPing_PingFinished
If spPing.pingResult.Success Then
Log("Success: " & spPing.pingResult.Success)
Log("To host: " & spPing.pingResult.toHost)
Log("To IP: " & spPing.pingResult.toIP)
Log("From host: " & spPing.pingResult.fromDest)
For Each bteKey As Byte In spPing.pingResult.mapResponse.Keys
Dim seqMap As Map = spPing.pingResult.mapResponse.Get(bteKey)
Log("Sequence " & bteKey & " - TTL : " & seqMap.Get("ttl") & " - Time : " & seqMap.Get("time"))
Next
Dim stats As Map = spPing.pingResult.mapStatistics
Log("Packets transmitted: " & stats.Get("packets transmitted"))
Log("Packets received: " & stats.Get("received"))
Log("Packets loss: " & stats.Get("packet loss"))
Log("Round Trip Time (Minimum): " & stats.Get("rtt min"))
Log("Round Trip Time (Average): " & stats.Get("rtt agv"))
Log("Round Trip Time (Maximum): " & stats.Get("rtt max"))
Log("Round Trip Time (Mean Deviation): " & stats.Get("rtt mdev"))
End If
End Sub
Private Sub SPPing_PingError(Msg As String)
Log(Msg)
End Sub
Private Sub Button1_Click
spPing.Start
End Sub