Android Question Url exist or not

parijs

Active Member
Licensed User
Longtime User
Hi, I am looking for code to check if a url still exists so that if it does not exist I will not go there
 

TILogistic

Expert
Licensed User
Longtime User
other:
Library NetWork
B4X:
' 
    Wait For (Ping("translate.google.com", 443)) Complete (Result As Boolean)
    Log(Result)
  
    Wait For (Ping("google.com", 443)) Complete (Result As Boolean)
    Log(Result)
  
    Wait For (Ping("b4x.com", 443)) Complete (Result As Boolean)
    Log(Result)
  
    Wait For (Ping("b4xxxx.com", 443)) Complete (Result As Boolean)
    Log(Result)
  
    Wait For (Ping("noooooooone.com", 443)) Complete (Result As Boolean)
    Log(Result)

B4X:
Public Sub Ping(Host As String, Port As Int) As ResumableSub
    Dim Socket As Socket
    Try
        Socket.Initialize("Socket")
        Socket.Connect(Host, Port, 60 * DateTime.TicksPerSecond)
        Wait For Socket_Connected (Successful As Boolean)
    Catch
        Log(LastException)
    End Try
    Return Successful
End Sub

 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…