Sub PingCamera (host As String, timeoutMs As Int) As Boolean
Private inetaddress As JavaObject
inetaddress.InitializeStatic("java.net.InetAddress")
Dim b As Boolean = inetaddress.RunMethodJO("getByName",Array As String(host)).RunMethod("isReachable",Array As Object(timeoutMs))
Return b
End Sub
Sub tim_tick
If Grabbing = False Then
Return
End If
Dim H As String = Get_Host(RTSP_URL)
If PingCamera(h, 500) = False Then
LastGrabbingError = H & " is not reachable"
Log(LastGrabbingError)
Return
Else
Log("!")
Get_Frame
End If
End Sub
'parse the host to use for Ping
Sub Get_Host(u As String) As String
Dim m As Matcher = Regex.Matcher("(.*:)//([A-Za-z0-9\-\.]+)(:[0-9]+)?(.*)", u)
Do While m.Find
For g = 1 To m.GroupCount
If g = 2 Then 'host name
Return m.Group(g)
End If
Next
Loop
Return ""
End Sub