Linux内核中的netlink套接字与从userland进行轮询有何不同? [英] How are netlink sockets in the Linux kernel different from polling from userland?

查看:226
本文介绍了Linux内核中的netlink套接字与从userland进行轮询有何不同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对netlink套接字在内核与应用程序交互上下文中的功能感到怀疑.如我所见,netlink套接字用于从内核到应用程序的基于事件的通知.这样做的好处是不需要轮询应用程序.

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.

但是与netlink套接字一样,它最终也将进行轮询以检查是否已从内核发送了一些数据.所以我的问题是,netlink套接字的这种功能与文件描述符的轮询有何不同? 我引用了,但是它告诉了如何使用netlink,而不是区别在netlink套接字和轮询之间.

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.

推荐答案

对于应用程序,netlink套接字和其他设备文件的行为大部分相似(即,调用pollread).

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

如果您需要netlink的功能之一(例如多播),或者您的驱动程序变得更易于实现(内核端API更类似于套接字并具有内置缓冲),则可以使用netlink,因为您不需要您必须自己编写文件操作.

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.

这篇关于Linux内核中的netlink套接字与从userland进行轮询有何不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆