Skip to content
Advertisement

How are netlink sockets in the Linux kernel different from polling from userland?

I have doubt about the functioning of netlink socket in kernel-application interaction context. As I have read that netlink socket is used for event based notification from kernel to application. The benefit of this is Application is not required to poll.

But as in case of netlink socket also, it will also be polling finally to check whether some data has been sent from kernel. So my question is, how this functioning of netlink socket is different from Polling of file decriptor? I refered this but it tells how to use netlink, not the difference between netlink socket and polling.

Advertisement

Answer

For applications, the behaviour of netlink sockets and other device files is mostly similar (i.e., calling poll and read).

You would use netlink if you need one of netlink’s features (such as multicast) or if your driver becomes easier to implement (the kernel-side API is more similar to a socket and has built-in buffering) because you don’t you have to write the file operations yourself.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement