iOS Question network error :-(

ivanomonti

Expert
Licensed User
Longtime User
Hi Erel;

how can I make sure that before you submit a query, check the network!
how can I keep the data flow under control"

Thank
 

davepamn

Active Member
Licensed User
Longtime User
I had to write a ping server function. It would be nice to have a network function call ping.

B4X:
Sub PingServer As Boolean

    Dim bRetVal As Boolean=False

    Try

        'Case 1

        Dim oPhone As Phone

        If oPhone.IsAirplaneModeOn=True Then

            bRetVal=False

            Return(bRetVal)

        EndIf

        Dim sDeviceIP As String

        'Check 4G connectivity

        sDeviceIP=myLan.GetMyIP

        'Msgbox(sDeviceIP,"IP address")

        If sDeviceIP<>"127.0.0.1" Then

            bRetVal=True

            Return(bRetVal)

        EndIf

       

        sDeviceIP=myLan.GetMyWifiIP

        If sDeviceIP="127.0.0.1" Then

            bRetVal=False

            Return(bRetVal)

        EndIf

        If oPhone.GetSettings("wifi_on")<>1 Then

            bRetVal=False

            Return(bRetVal)

        EndIf

        If oPhone.GetDataState="DISCONNECTED" Then

            bRetVal=True

        Else

            bRetVal=False   

        EndIf



    Catch

        oError.ShowLastException("Error Ping")

    EndTry

    Return(bRetVal)

   

End Sub
 
Upvote 0
Top