TCP/IP conexion

charro98120165

Member
Licensed User
Longtime User
hi, im treat test conexion tcp ip but i get an error "libcore.io.ErnoException:isConected failed EHOSTUNREACH (NO route to host)
I can do to fix this??

thanks, and sorry for my english :)
 

sangee

Member
Licensed User
Longtime User
Check the below code... this checks if you have a active TCP connection either on GPRS or Wifi...

B4X:
Public Sub CheckConnection As Boolean 
   Dim ph As Phone
   Dim Strvalue As String 
   Dim CurValue As Int 

   Try

       Dim myLAN As ServerSocket
       If ph.GetDataState <> "CONNECTED" AND myLAN.GetMyIP = "127.0.0.1" Then
            'Looks like we do not have a internet connection. 
            'Run your code here when there is no connection

      Else
      'ok we are connected. Run your code to do what needs to be done when there is a internet connection   
                End If
   Catch
      Log ("Error in Check connnection sub in Checkstat service")
      Return
   End Try
End Sub
 
Upvote 0
Top