blocking on socket I/O and classic API

Adit Sahasrabudhe asahasra at fb.com
Wed Apr 13 01:52:03 UTC 2016


Thank you Paul, that is very helpful. 

A follow on question: we tried using mqueue instead of the classic api queue, since it is supposed to be compatible with select, but for some reason the file descriptor returned on mq_open is too large for select to accept. 

Then we thought about using poll instead of select (better performance anyway), and though I can see poll in the source code, it is not contained in the librtemscpu library in our bsp. Should I be able to use poll? We are on an altera cyclone v board. 

Adit

> On Apr 12, 2016, at 5:52 PM, Paul Whitfield <paulw at omnitronics.com.au> wrote:
> 
> Hi 
> 
> I don’t think there is a way to keep the blocking select and do this.
> 
> The usual way we do this is: 
> 
>    - Set socket to non-blocking
>    - Use setsockopt() to install a SO_RCVWAKEUP to install a receive callback on the socket
>    - In the receive callback send a message to the classic message queue to notify the task data is available
> 
> The processing/destination task waits for a message on the queue, 
>    - if the message from the receive callback the task then reads from the socket to get the received data. 
>    - If the message is some “other” request then it processes that. 
> 
> This generally works well for us. 
> The only thing to make sure is that the processing task completely reads all the received data to "re-arm" the receive call back.
> 
> 
> Best regards
> 
> Paul Whitfield.
> 
> 
> From: users [mailto:users-bounces at rtems.org] On Behalf Of Adit Sahasrabudhe
> Sent: Wednesday, 13 April 2016 2:58 AM
> To: users at rtems.org
> Subject: blocking on socket I/O and classic API
> 
> Hi all,
> 
> This is really a general question about mixing POSIX API calls and Classic API ones. We are using networking in our system (ARM Cortex-A9 based), so we have a task that is blocking on a socket file descriptor, just using a select() call. We are using RTEMS classic API for tasks and semaphores. We want to add a message queue to this task, and would like to have it be asynchronous, so that we can have a single blocking call that waits for either the socket FD or a message queue.
> 
> Is there a way to mix the classic message queue API with a socket FD for blocking? What are the ways in which people do this?
> 
> Thanks,
> Adit


More information about the users mailing list