I was wondering if there is any way to setup a callback when data is received on an open socket, as opposed to just regularly polling the socket?
The application I have maintains two open sockets, one is a UDP socket listener, the other is an AT socket to catch URCs.
Currently I regularly poll both of the sockets (non-blocking using the MSG_DONTWAIT flag) using a timer setup (K_TIMER).
I understand that there are a number of ways of a-synchronously polling the socket and then effectively creating my own callback system. However, I was wondering if there is any way to setup a direct callback which is triggered by whatever system actually sends the data to the socket?
The main reason for this is to reduce power consumption. Frequently (1Hz) polling the sockets has a significant proportional impact on the average power consumption when in the idle phase of PSM or eDRX. I can reduce the polling frequency but this introduces additional latency. A callback would preferable, where a notification of some form is provided when data arrives at a given socket.
I imagine that the two socket types I am using might require separate solutions.