Android Question Ping error "icmp open socket: Operation not permitted" (First Post)

diegoferreira

Member
Licensed User
Longtime User
Hola, Hi !

This code only pings if phone is root. Otherwise I get the following error.

Este codigo solo hace ping si el telefono esta root. De lo contrario me da el siguiente error.

Ping error "icmp open socket: Operation not permitted"

B4X:
Sub Ping( Server As String, Count As Int ) As String 'Root requiere.
    Dim P As Phone, StringBuilderOut, StringBuilderErr As StringBuilder
  
    StringBuilderOut.Initialize
    StringBuilderErr.Initialize
  
    P.Shell( "ping -c" & Count & " " & Server, Null, StringBuilderOut, StringBuilderErr )
    If StringBuilderErr.Length = 0 Then
        Return StringBuilderOut.ToString
    Else
        Return "error: " & StringBuilderErr.ToString
    End If
End Sub
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…