Is there a fast way to check online status?

Just starting out? Need help? Post your questions and find answers here.
jamba
Enthusiast
Enthusiast
Posts: 144
Joined: Fri Jan 15, 2010 2:03 pm
Location: Triad, NC
Contact:

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

Post 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/"))
-Jon

Fedora user
But I work with Win7