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

孤街醉人 提交于 2020-01-04 03:52:17

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/16727212/how-are-netlink-sockets-in-the-linux-kernel-different-from-polling-from-userland

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!