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

2

9

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 API 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?

Seiler answered 21/12, 2010 at 11:57 Comment(0)
R
4

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

Robins answered 8/1, 2011 at 17:18 Comment(0)
A
-3

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.

Adallard answered 21/12, 2010 at 12:25 Comment(1)
I am not talking about listening socket and sending and receiving data from socket. I am talking about getting network adapter settings and configuration data by using NETLINK socket API. Netlink is a socket-like mechanism for IPC between the kernel and user space processes, as well as between user space processes alone (like e.g., unix sockets) or a mixture of multiple user space and kernel space processes. My investigation shows me that there is not NETLINK API for mac os x. I am looking for some kind of substitute for it. P.S. epoll() system call doesn’t exist in MAC OS X 8-)Seiler

© 2022 - 2024 — McMap. All rights reserved.