wasi-sockets: Introduce UDP streams#7243
Conversation
|
Thanks for this! I've got a few comments on some API design decisions as well as their implications on the implementation:
|
I agree, yet I couldn't figure out how to make it work.
I (tried to) use the wasi-http naming scheme, as they feel more natural to the domain at hand (networking) as opposed to input&output. For the stream types, I'm fine with either naming scheme. They're temporary anyway.
Good point. I'll look into it.
Even with a |
|
One way to get invalidation working without For naming ok sounds like we're already a bit inconsistent, so I think it's ok to keep the names here 👍 For |
|
Potentially answering my own question:
Rather than performing validation in the *-stream code, maybe we can require the consumer to have dropped all prior child streams before calling |
|
Ah I think we raced there a bit, but I like your idea more of requiring the streams are dropped than my idea of a generation counter |
Introduce new `inbound-datagram-stream` and `outbound-datagram-stream` types and moved `receive` and `send` methods to those respectively. These streams are returned by `bind` can be individually subscribed to. This resolves a design issue where a UDP server would end up in a spin loop because `receive` returned EWOULDBLOCK but poll_* always returned immediately because the socket was ready for sending. In this new setup, users can poll each direction separately. Fixes WebAssembly/wasi-sockets#64 Additionally: - Enable send-like behaviour by making `outbound-datagram::remote-address` optional. Fixes WebAssembly/wasi-sockets#57 - Dropped the `network` parameter from the `connect` call, because `bind` is now _required_ to perform IO.
Remove the Mutex again. Instead allow `stream` to be called multiple times, but trap if the previous streams are still active.
|
This is ready for review again. I have:
|
alexcrichton
left a comment
There was a problem hiding this comment.
Looks great to me, thanks again for this!
|
Alright, looks like the MacOS issue is fixed now |
Introduce new
inbound-datagram-streamandoutbound-datagram-streamtypes and movedreceiveandsendmethods to those respectively. These streams are returned bybindand can be individually subscribed to. This resolves a design issue where a UDP server would end up in a spin loop becausereceivereturned EWOULDBLOCK but poll_* always returned immediately because the socket was ready for sending. In this new setup, users can poll each direction separately. Fixes WebAssembly/wasi-sockets#64Additionally
outbound-datagram::remote-addressoptional. Fixes UDP: Enablesend-like behaviour WebAssembly/wasi-sockets#57networkparameter from theconnectcall, becausebindis now required to perform IO.