int psock_poll(FAR struct socket *psock, FAR struct pollfd *fds, bool setup) { int ret; #ifdef CONFIG_NET_UDP /* poll() not supported for UDP */ if (psock->s_type != SOCK_STREAM) { return -ENOSYS; } #endif /* Check if we are setting up or tearing down the poll */ if (setup) { /* Perform the TCP/IP poll() setup */ ret = net_pollsetup(psock, fds); } else { /* Perform the TCP/IP poll() teardown */ ret = net_pollteardown(psock, fds); } return ret; }
int net_poll(int sockfd, struct pollfd *fds, bool setup) { #ifndef HAVE_NETPOLL return -ENOSYS; #else FAR struct socket *psock; int ret; /* Get the underlying socket structure and verify that the sockfd * corresponds to valid, allocated socket */ psock = sockfd_socket(sockfd); if (!psock || psock->s_crefs <= 0) { ret = -EBADF; goto errout; } #ifdef CONFIG_NET_UDP /* poll() not supported for UDP */ if (psock->s_type != SOCK_STREAM) { ret = -ENOSYS; goto errout; } #endif /* Check if we are setting up or tearing down the poll */ if (setup) { /* Perform the TCP/IP poll() setup */ ret = net_pollsetup(psock, fds); } else { /* Perform the TCP/IP poll() teardown */ ret = net_pollteardown(psock, fds); } errout: return ret; #endif /* HAVE_NETPOLL */ }