blocking on socket I/O and classic API
Paul Whitfield
paulw at omnitronics.com.au
Wed Apr 13 00:52:42 UTC 2016
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