title: recvmsg with select on NETLINK socket
body: <p>I am writing NETLINK xfrm socket programming to create association and policies for ESP communication. To send the data to kernel</p>
  <pre><code>sockfd = socket(AF_NETLINK, SOCK_RAW|SOCK_CLOEXEC, NETLINK_XFRM);
  setsockopt(sockfd, SOL_SOCKET, SO_SNDBUF, &amp;sckbuff, sizeof(sckbuff));
  setsockopt(sockfd, SOL_SOCKET, SO_RCVBUF, &amp;sckbuff, sizeof(sckbuff));
  bind(sockfd, (struct sockaddr *)&amp;addr, sizeof(struct sockaddr_nl));
  ...
  memset(&amp;msg, 0, sizeof(struct msghdr));
  msg.msg_name = (void *)&amp;(addr);
  msg.msg_namelen = sizeof(addr);
  ...
  memset(&amp;iov, 0, sizeof(struct iovec));
  iov.iov_base = (void *)netlink_req;
  iov.iov_len = netlink_req-&gt;nlmsg_len;
  
  msg.msg_iov = &amp;iov;
  msg.msg_iovlen = 1;
  
  sendmsg(sockfd, &amp;msg, 0);
  
  </code></pre>
  <p>And to receive the response from kernel</p>
  <pre><code>while(true)
  {
    ...
    FD_ZERO(&amp;readfds);
    FD_SET(sockfd, &amp;readfds);
    select(sockfd+1, &amp;readfds, NULL, NULL, NULL);
  
    read_len = recvmsg(sockfd, &amp;msg, MSG_PEEK);
    printf(&quot;Data received %d\n&quot;, read_len);
    for (nh = (struct nlmsghdr *) buf;
       NLMSG_OK (nh, read_len);
       nh = NLMSG_NEXT (nh, read_len))
    {
      if (nh-&gt;nlmsg_type == NLMSG_DONE)
      {
            break;
      }
      else if (nh-&gt;nlmsg_type == NLMSG_ERROR)
      {
        ...
      }
      ...
    }
  }
  ...
  </code></pre>
  <p>It is working file if recvmsg is done sequentially without <code>select</code>.</p>
  <p>But when i tried to send multiple request and do <code>select</code> with <code>sockfd</code> in another thread then <code>recvmsg</code> continue to receive the same message and never stop.</p>
  <p>Is there any flag i need to set in response to stop the continuous loop or any other way?</p>