You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2021/07/02 08:51:38 UTC

[GitHub] [incubator-nuttx] moataz-metwally edited a comment on issue #4037: Raw socket doesnot support non blocking flags including poll and select and any async read access

moataz-metwally edited a comment on issue #4037:
URL: https://github.com/apache/incubator-nuttx/issues/4037#issuecomment-872833348


   Here is a sample code that works on linux but does not work on Nuttx btw there are some other issue with the net subsystem other than this issue but we can address it later.
   
   ```
   #define ETH_SOCS_CNT 1
   #define ETH_SOC_FD 0
   #define POLL_TIMEOUT_MSEC   1
   int socket_fd;
   int ret = socket(AF_PACKET, SOCK_RAW | SOCK_NONBLOCK  , 0); 
   if (ret == -1)
   {
   	printf("Cannon open ETH socket\n");
   	
   }
   socket_fd = ret;
   
   
   poll_fds[ETH_SOC_FD].fd = socket_fd;
   poll_fds[ETH_SOC_FD].events = POLLIN | POLLPRI;
   
   rc = ioctl(socket_fd, FIONBIO, (char*) &on); /* will fail with errno 88 */
   if (rc < 0) {
   	printf("ioctl() failed:%d\r\n",errno);
   }
   
   int events_num = poll(poll_fds, ETH_SOCS_CNT, POLL_TIMEOUT_MSEC);
   printf("events_num:%x\r\n",events_num);
   
   if (events_num < 0) {
   	printf("Poll error: %d\r\n", errno); /* will fail with errno 88 */
   }
   
   
   
   
   
   ```
   
   
   
   You can go to net/socket/pkt_sockif.c, you will find that there is no any implementation for the poll and pkt_sockcaps.
   the net subsystem as I see it uses pkt_sockcaps to get the flags set for the sockets, in case of raw socket , as you see, it returns zero so SOCK_NONBLOCK  flag is not taken into account.
   
   
   Other issue with sendto, raw sockets doesnot support the use of sendto while on linux it works.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org