I found that when giving a callback to S.UDP.listen, the unix stack blocks on the callback before receving next UDP datagram - but the direct stack doesn't.
My usecase has been to implement TCP-like semantics on top of UDP in the conntest unikernel. As the lifetime of the callback in this case is as long as the 'UDP connection', then the callback need to be run async and potentially saved elsewhere for managing the state of the thread.
This is fine for me in this case (when I know of the semantics), but I was initially confused that the UDP callback wasn't run right away when a datagram was received - this could become a more subtle problem to find for some users, if their callback takes a bit of time but they expect it to be run instantly on each datagram. Off the top of my head this can influence:
- performance of code using UDP
- potential loss of datagrams if some underlying buffer gets filled before next datagram is read by client (I'm unaware of the actual underlying semantics)
Otoh. when callbacks are run concurrently, it can lead to a need for the client to synchronize between the callbacks if they mutate anything.
In any case, documentation of the semantics would be nice, and having the same behaviour across stacks.
I found that when giving a callback to
S.UDP.listen, theunixstack blocks on the callback before receving next UDP datagram - but thedirectstack doesn't.My usecase has been to implement TCP-like semantics on top of UDP in the
conntestunikernel. As the lifetime of the callback in this case is as long as the 'UDP connection', then the callback need to be run async and potentially saved elsewhere for managing the state of the thread.This is fine for me in this case (when I know of the semantics), but I was initially confused that the UDP callback wasn't run right away when a datagram was received - this could become a more subtle problem to find for some users, if their callback takes a bit of time but they expect it to be run instantly on each datagram. Off the top of my head this can influence:
Otoh. when callbacks are run concurrently, it can lead to a need for the client to synchronize between the callbacks if they mutate anything.
In any case, documentation of the semantics would be nice, and having the same behaviour across stacks.