开发者

Does anybody know equivalent for NETLINK Sockets API for MAC OS X?

Does anybody know equivalent for NETLINK Sockets API for MAC OS X ? I am trying to port Linux application to MAC OS X and I couldn’t find anything similar in MACOS.

I need to provide asynchronous access to the network adapter in my application.

Polling network adapter about configuration changes etc every certain amount of seconds is not convenient solution for me. NETLINK Socket AP开发者_如何学运维I game me way to receive notification only when something interesting happened.

I know that NETLINK is Linux specific thing to communicate between Linux kernel and user space, but maybe there is exist something like NETLINK under MACOS.

I see the the only tool to communicate with kernel – sysctl()

Does anybody have any info?


You can use the kernel control architecture which is documented in the NKE section of their docs that OSX provides for that reason.


The traditional way of doing this is to wait for events on the socket using select/poll/epoll/kqueue. See this answer for what is best on what platform: select vs poll vs epoll.

Alternatively, spawn a new thread for each connection and use blocking socket reads. Though, history have taught us that this is less scalable than non-blocking I/O via select/poll/kqueue. This was the way most people originally wrote network servers in the 1990s. Depending on your coding style, blocking I/O + threads may be easier to work with.

Note that contrary to its name, epoll is not polling.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜