Check, if online using CallBack
Posted: Fri May 11, 2012 1:00 pm
EDIT: For your interest, I removed the question dealing with this, as I think, we found a solution. See the 4th post below by me.
-----
Hi board,
I'd like to share a sample-function to get information about the online-state.
Not with Callback, as I asked here: http://purebasic.fr/english/viewtopic.php?f=19&t=49841
Hope someone can use it. Comments welcome, especially if usable everywhere
If someone has any hint about using a CallBack, please do so... I am interested!
-----
Hi board,
I'd like to share a sample-function to get information about the online-state.
Not with Callback, as I asked here: http://purebasic.fr/english/viewtopic.php?f=19&t=49841
Hope someone can use it. Comments welcome, especially if usable everywhere

If someone has any hint about using a CallBack, please do so... I am interested!
Code: Select all
ImportC "/System/Library/Frameworks/SystemConfiguration.framework/SystemConfiguration"
SCNetworkCheckReachabilityByName(target.i,status.i)
EndImport
#NetWork_No_Server = 0
#NetWork_Is_Online = 2
#NetWork_Is_Offline = 7
Procedure Check_Connectivity(URL.s)
Protected status.i = 0
Protected result.i = 0
result = SCNetworkCheckReachabilityByName(@url,@status)
If result
ProcedureReturn status
EndIf
EndProcedure
status = Check_Connectivity("www.apple.com")
Select Status
Case #NetWork_No_Server : Debug "Don't know this server!"
Case #NetWork_Is_Online : Debug "Online!"
Case #NetWork_Is_Offline : Debug "Offline!"
EndSelect