-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great to me, thanks again for this!
Alright, looks like the MacOS issue is fixed now |
Introduce new
inbound-datagram-stream
andoutbound-datagram-stream
types and movedreceive
andsend
methods to those respectively. These streams are returned bybind
and can be individually subscribed to. This resolves a design issue where a UDP server would end up in a spin loop becausereceive
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#64Additionally
outbound-datagram::remote-address
optional. Fixes UDP: Enablesend
-like behaviour WebAssembly/wasi-sockets#57network
parameter from theconnect
call, becausebind
is now required to perform IO.