Closed domenic closed 2 years ago
We have a sequence, but there is back pressure: each send()
returns a Promise. Clients can wait for the promise to resolve before sending another datagram.
The API is designed to be future compatible with one day exchanging datagrams with more that one specific peer. ReadableStream
/ WritableStream
would likely make that more awkward.
Can you explain more about why it'd be more awkward to use streams? Async iterators seem like they'd have the same issues.
This can be closed now as we adopted streams for udp and landed the respective cl-s.
There are basically two models for programming against UDP sockets:
This spec seems to have chosen (2), since it uses async iterables (which have a built-in buffer of that sort)... but it did so without using the streams API. If (2) is indeed the desired design, then I suggest using
ReadableStream
/WritableStream
.FWIW, we had a similar discussion in the early days of the streams API around https://github.com/sysapps/tcp-udp-sockets, which ended up using (2).