Hi, I have a function just like this:
static int
rcv_kern(int sock, void *buf, int len, struct sockaddr *addr,
socklen_t *addrlen)
{
struct timeval timeout = {1, 0};
fd_set set;
int status;
FD_SET(sock, &set);
if ((status = select(sock + 1, &set, NULL, NULL, &timeout)) == 0) {
FD_ZERO(&set);
fprintf(stderr,
"timeout while receiving answer from kernel\n");
exit(1);
} else if (status == -1) {
FD_ZERO(&set);
perror("recvfrom failed");
exit(1);
}
FD_ZERO(&set);
return recvfrom(sock, buf, len, 0, addr, addrlen);
}
which is used for receiving message from kernel space using netlink. But when I run it, the result always says the message that "timeout while reciving answer from kernel", from the source code, this causes by the reason that the "select" method always return '0'. I don't know the reason, who can give me some suggestions, thanks.