Closed
Description
In blocking mode, for example:
- create, open and bind a UDP socket
- attach the socket to a callback function
- receiving a UDP packet on the listening port triggers the callback
- call recvfrom to retrieve the data
- an event seems to be pending, which blocks any subsequently received UDP packets from triggering the callback
In step 4, it seems that the _pending
flag is cleared before socket_recvfrom()
is called, which in turn triggers the event callback again setting the _pending
flag again.
In non-blocking mode the recvfrom call in step 4 also triggers another callback, but a 2nd recvfrom call (which returns NSAPI_ERROR_WOULD_BLOCK) clears the flag, allowing new events to trigger the callback.
The same thing seems to happen with at least UDPSocket::recvfrom, TCPSocket::recv and TCPServer::accept.
Is this the intended behaviour? Have to use non-blocking sockets and make the call twice to clear the pending event to be able to receive new ones?
Metadata
Metadata
Assignees
Labels
No labels