简体   繁体   中英

Is netlink socket a client/server mode?

Now I am meeting a trouble:My netlink is used for kernel and user space communication. When I only start the user space's netlink socket, it will give me an error:

proctol not supported

My source code is:

if((sk_fd = socket(PF_NETLINK, SOCK_RAW, netlink_id)) == -1)
    {
        printf("socket error:%s\n", strerror(errno));
        return false;
    }

which netlink_id is 1567. But when I start the kernel netlink in advance, it will work well. So I think the netlink is ac/s model. Do you agree with me?

For the question, I have tried many ways to test.Now I had a conclusion: When we used netlink for communication between kernel and user's space, you must create netlink in kernel first and started success, the netlink socket in user's space could only create success. So the communication could only establish success when you did above well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM