Hey everyone

First, thanks for the great examples!
I am trying to get it work with the Procedure:
SCNetworkReachabilityCreateWithAddressPair
But I dont get it

Does anyone know how this works?
Here the Apple reference
https://developer.apple.com/documentati ... guage=objc
Code: Select all
EnableExplicit
Structure sockkaddr
sa_family.a
sa_data.s
EndStructure
Structure in_addr
s_addr.l
EndStructure
Structure sockaddr_in
sin_addr.in_addr
sin_family.w
;sin_len.i
sin_port.u
;sin_zero.a[8]
EndStructure
ImportC "-framework SystemConfiguration"
dispatch_queue_create(label.p-utf8, attr.i)
SCNetworkReachabilityCreateWithAddressPair(allocator.i, *localAddress.sockaddr_in, *remoteAddress.sockaddr_in)
SCNetworkReachabilitySetCallback(target.i, callout.i, context.i)
SCNetworkReachabilitySetDispatchQueue(target.i, queue.i)
EndImport
#kSCNetworkReachabilityFlagsReachable = 2
#AF_INET = 2 ; Internet IP Protocol
Global reachability = #Null
Global reachabilitySerialQueue = dispatch_queue_create("com.pb_example.reachability", #Null)
Global localAddress.sockaddr_in
Global remoteAddress.sockaddr_in
Procedure Init_CallBack()
localAddress\sin_addr\s_addr = 3232240180
localAddress\sin_family = #AF_INET
localAddress\sin_port = 3490
remoteAddress\sin_addr\s_addr = 3232240180
remoteAddress\sin_family = #AF_INET
remoteAddress\sin_port = 3490
If reachability = #Null
reachability = SCNetworkReachabilityCreateWithAddressPair(#Null, @localAddress, @remoteAddress)
Debug reachability
If reachability
Debug "Reachability reference created!"
Else
Debug "error"
EndIf
EndIf
EndProcedure
;- main
Init_CallBack()
OpenWindow(0,100,100,100,100,"bla")
;- loop
Repeat
Define event = WaitWindowEvent(500)
Until event = #PB_Event_CloseWindow
; Cleanup
If reachability
SCNetworkReachabilitySetCallback(reachability, #Null, #Null)
SCNetworkReachabilitySetDispatchQueue(reachability, #Null)
CFRelease_(reachability)
reachability = #Null
EndIf