stopping a task from updateHook

Hi again,

We're still working on the Socket class implementation and have found
one more problem. We are implementing our task as a non-periodic
activity with active polling.

The problem we're facing is as follows. When the socket created is a
stream socket, we check if the network peer is disconnected, looking
at the return value of recv function at each updateHook call. In case
it returns 0, meaning the network peer has disconnected, we'd like to
change the task state to stopped.

We've tried to call stop() from inside the updateHook function, but it
seems that it cannot take effect until updateHook is exited, which
will never happen since it is waiting for stop() function to return
(this is our guess, the fact is that we've checked that stop() blocks,
and this is how we interpret what's happening).

We've also tried using events but in this case, the event handler also
blocks when calling stop(), and updateHook blocks when launching the
event (aren't events supposed to be asynchronous?).

Which would be the best way to solve this?

Greetings,
Miguel.