Skip to content
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] Support wasi-sockets and wasi-http #98957

Closed
dicej opened this issue Feb 26, 2024 · 6 comments
Closed

[wasi] Support wasi-sockets and wasi-http #98957

dicej opened this issue Feb 26, 2024 · 6 comments
Assignees
Labels
arch-wasm WebAssembly architecture area-System.Net.Http os-wasi Related to WASI variant of arch-wasm
Milestone

Comments

@dicej
Copy link
Contributor

dicej commented Feb 26, 2024

WASI 0.2.0 introduces two new networking APIs: wasi-sockets (for TCP/UDP networking and hostname lookup) and wasi-http (a high-level API for handling inbound HTTP requests and sending outbound ones). Ideally, the WASI port of the .NET should support both.

Dave Bakker and I have implemented wasi-sockets in a temporary fork of wasi-libc, and I'm currently in the process of incrementally merging that work upstream, with the aim of making it available as part of the forthcoming WASI-SDK 22 release. I've also created temporary forks of Rust and CPython based on the wasi-libc work and plan to upstream those changes as well. Similarly, I'm hoping it will be straightforward to add wasi-sockets support to .NET as well by way of the POSIX APIs provided by wasi-libc.

Given that there's no C standard library or POSIX interface for HTTP, it won't be supported as part of wasi-libc, so porting e.g. System.Net.Http to use wasi-http will presumably involve wrapping wit-bindgen-generated C or C# code, depending on how solid the C# binding generator is.

I should note that I have close to zero experience with .NET, so I'm happy to defer to the experts here about the details of how all this should proceed. I'm also happy to learn and contribute as appropriate.

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Feb 26, 2024
@ghost
Copy link

ghost commented Feb 26, 2024

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

Issue Details

WASI 0.2.0 introduces two new networking APIs: wasi-sockets (for TCP/UDP networking and hostname lookup) and wasi-http (a high-level API for handling inbound HTTP requests and sending outbound ones). Ideally, the WASI port of the .NET should support both.

Dave Bakker and I have implemented wasi-sockets in a temporary fork of wasi-libc, and I'm currently in the process of incrementally merging that work upstream, with the aim of making it available as part of the forthcoming WASI-SDK 22 release. I've also created temporary forks of Rust and CPython based on the wasi-libc work and plan to upstream those changes as well. Similarly, I'm hoping it will be straightforward to add wasi-sockets support to .NET as well by way of the POSIX APIs provided by wasi-libc.

Given that there's no C standard library or POSIX interface for HTTP, it won't be supported as part of wasi-libc, so porting e.g. System.Net.Http to use wasi-http will presumably involve wrapping wit-bindgen-generated C or C# code, depending on how solid the C# binding generator is.

I should note that I have close to zero experience with .NET, so I'm happy to defer to the experts here about the details of how all this should proceed. I'm also happy to learn and contribute as appropriate.

Author: dicej
Assignees: -
Labels:

area-System.Net.Http, untriaged

Milestone: -

@MihaZupan MihaZupan added os-wasi Related to WASI variant of arch-wasm arch-wasm WebAssembly architecture labels Feb 27, 2024
@ghost
Copy link

ghost commented Feb 27, 2024

Tagging subscribers to 'arch-wasm': @lewing
See info in area-owners.md if you want to be subscribed.

Issue Details

WASI 0.2.0 introduces two new networking APIs: wasi-sockets (for TCP/UDP networking and hostname lookup) and wasi-http (a high-level API for handling inbound HTTP requests and sending outbound ones). Ideally, the WASI port of the .NET should support both.

Dave Bakker and I have implemented wasi-sockets in a temporary fork of wasi-libc, and I'm currently in the process of incrementally merging that work upstream, with the aim of making it available as part of the forthcoming WASI-SDK 22 release. I've also created temporary forks of Rust and CPython based on the wasi-libc work and plan to upstream those changes as well. Similarly, I'm hoping it will be straightforward to add wasi-sockets support to .NET as well by way of the POSIX APIs provided by wasi-libc.

Given that there's no C standard library or POSIX interface for HTTP, it won't be supported as part of wasi-libc, so porting e.g. System.Net.Http to use wasi-http will presumably involve wrapping wit-bindgen-generated C or C# code, depending on how solid the C# binding generator is.

I should note that I have close to zero experience with .NET, so I'm happy to defer to the experts here about the details of how all this should proceed. I'm also happy to learn and contribute as appropriate.

Author: dicej
Assignees: -
Labels:

arch-wasm, area-System.Net.Http, untriaged, os-wasi

Milestone: -

@MichalPetryka
Copy link
Contributor

Would wasi-sockets require some new API like WebSockets and WebRTC do or are they compatible with normal Sockets?

@dicej
Copy link
Contributor Author

dicej commented Feb 27, 2024

Would wasi-sockets require some new API like WebSockets and WebRTC do or are they compatible with normal Sockets?

Unlike WebSockets and WebRTC, which represent novel protocols, wasi-sockets is only concerned with TCP and UDP network sockets (plus domain name lookups). It intentionally mirrors the Berkeley/POSIX interface for Internet sockets, with tweaks to make it more capability-oriented in keeping with the WASI security model. And even that capability model is abstracted away by wasi-libc, so .NET's existing System.Net.Sockets APIs should work fine. In fact, we should be able to share the existing implementation of those APIs with other POSIX-style systems .NET already supports.

@lewing lewing added this to the 9.0.0 milestone Mar 15, 2024
@lewing lewing removed the untriaged New issue has not been triaged by the area owner label Apr 12, 2024
@pavelsavara
Copy link
Member

let's do it 😄

@pavelsavara
Copy link
Member

Fixed by #106977 and #103752

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arch-wasm WebAssembly architecture area-System.Net.Http os-wasi Related to WASI variant of arch-wasm
Projects
None yet
Development

No branches or pull requests

5 participants