开发者

how to detect network event in cocoa osx

开发者 https://www.devze.com 2022-12-23 00:12 出处:网络
Is it possible to make sure my thread reacts on whenever 开发者_高级运维there is network available ? Basically my thread should automatically get event that network is available and perform certain ta

Is it possible to make sure my thread reacts on whenever 开发者_高级运维there is network available ? Basically my thread should automatically get event that network is available and perform certain task.

Any help will be appreciated.


Yes you can, use Reachability APIs in SystemConfiguration.framework. See here. A sample code (for iphone) is available here. The parts concerning the reachability APIs should be usable for OS X, too.

To use the APIs, you need to understand an OS X specific concept of "run loops." See here.


I found a way of getting network change event using growl framework. Added code on top of it to receive network change event. Growl framework can be found at http://growl.info/documentation/developer/

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号