Hello ,
I am currently using this to check if I am online...
InitNet=InitNetwork()
resultr= ReceiveHTTPFile("http://www.mywebsite.com/abc.htm", Filename1$)
to see if I get the file. If I dont, it is offline. If I do I know I am online.
Is there a better way or faster way to do this? .. to know if the computer is online?
Thanks
Alan
Is there a fast way to check online status?
Re: Is there a fast way to check online status?
Code: Select all
Procedure IsOnline(URL$)
Protected ServerName$ = GetURLPart(URL$, #PB_URL_Site)
Protected ConnectionID = OpenNetworkConnection(ServerName$, 80)
If ConnectionID
CloseNetworkConnection(ConnectionID)
ProcedureReturn #True
EndIf
EndProcedure
InitNetwork()
Debug IsOnline("http://www.google.de/")
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and more ― Typeface - Sprite-based font include/module
Lizard - Script language for symbolic calculations and more ― Typeface - Sprite-based font include/module
Re: Is there a fast way to check online status?
Thanks Stargate.
Alan
Alan
Re: Is there a fast way to check online status?
True was being returned for everything I tried so I made a minor modification or two, hope you don't mind

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