Is netlink socket a client/server mode?

461 Views Asked by At

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 a c/s model. Do you agree with me?

1

There are 1 best solutions below

0
On BEST ANSWER

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.