Page 1 of 1

Re: Is there a fast way to check online status?

Posted: Thu May 20, 2010 1:18 pm
by jamba
True was being returned for everything I tried so I made a minor modification or two, hope you don't mind :D

Code: Select all

Procedure IsOnline(URL$)
  If FindString(URL$,"http://",1)
    Protected ServerName$ = GetURLPart(URL$, #PB_URL_Site)
  Else
    ServerName$ = URL$
  EndIf
  Debug ServerName$
  If ServerName$ = ""
    ProcedureReturn #False
  EndIf
  
  Protected ConnectionID = OpenNetworkConnection(ServerName$, 80)
  If ConnectionID
    CloseNetworkConnection(ConnectionID)
    ProcedureReturn #True
  EndIf
  ProcedureReturn #False
EndProcedure

InitNetwork()
Debug "Is online: " + Str(IsOnline("74.125.159.106"))
Debug "Is online: " + Str(IsOnline("blahblah"))
Debug "Is online: " + Str(IsOnline("http://www.google.de/"))