haraldh edited PR #3711 from wasmtime_sock_accept to main:
Together with https://github.com/rust-lang/rust/pull/93158 this enables basic networking in rust.
TODO:
- [ ] Test cases
- [ ] Discussion of
SocketAddrreturn value for::accept()in the rustsrc PROk(( TcpStream::from_inner(unsafe { Socket::from_raw_fd(fd as _) }), // WASI has no concept of SocketAddr yet // return an unspecified IPv4Addr SocketAddr::new(Ipv4Addr::UNSPECIFIED.into(), 0), ))Followup Todo: * [ ] PR with CLI option to specify
ListenFds * [ ] Wasi definition ofPreopentypefor sockets (listener and stream, tcp and unix) * [ ] Non-busy polling on Windows
haraldh edited PR #3711 from wasmtime_sock_accept to main:
Together with https://github.com/rust-lang/rust/pull/93158 this enables basic networking in rust.
Todo
- [ ] Test cases
- [ ] Discussion of
SocketAddrreturn value for::accept()in the rustsrc PROk(( TcpStream::from_inner(unsafe { Socket::from_raw_fd(fd as _) }), // WASI has no concept of SocketAddr yet // return an unspecified IPv4Addr SocketAddr::new(Ipv4Addr::UNSPECIFIED.into(), 0), ))Followup Todo
- [ ] PR with CLI option to specify
ListenFds: https://github.com/bytecodealliance/wasmtime/pull/3729- [ ] Wasi definition of
Preopentypefor sockets (listener and stream, tcp and unix)- [ ] Non-busy polling on Windows
haraldh submitted PR review.
haraldh created PR review comment:
moved CLI PR to https://github.com/bytecodealliance/wasmtime/pull/3729
haraldh submitted PR review.
haraldh created PR review comment:
moved CLI PR to https://github.com/bytecodealliance/wasmtime/pull/3729
haraldh has marked PR #3711 as ready for review.
haraldh edited PR #3711 from wasmtime_sock_accept to main:
Together with https://github.com/rust-lang/rust/pull/93158 this enables basic networking in rust.
See https://github.com/bytecodealliance/wasmtime/issues/3730 for the tracking issue.
Todo
- [ ] Test cases
- [ ] Discussion of
SocketAddrreturn value for::accept()in the rustsrc PROk(( TcpStream::from_inner(unsafe { Socket::from_raw_fd(fd as _) }), // WASI has no concept of SocketAddr yet // return an unspecified IPv4Addr SocketAddr::new(Ipv4Addr::UNSPECIFIED.into(), 0), ))Followup Todo
- [ ] PR with CLI option to specify
ListenFds: https://github.com/bytecodealliance/wasmtime/pull/3729- [ ] Wasi definition of
Preopentypefor sockets (listener and stream, tcp and unix)- [ ] Non-busy polling on Windows
haraldh edited PR #3711 from wasmtime_sock_accept to main:
Together with https://github.com/rust-lang/rust/pull/93158 this enables basic networking in rust.
See https://github.com/bytecodealliance/wasmtime/issues/3730 for the tracking issue.
Todo
- [ ] Test cases
Followup Todo
- [ ] PR with CLI option to specify
ListenFds: https://github.com/bytecodealliance/wasmtime/pull/3729- [ ] Wasi definition of
Preopentypefor sockets (listener and stream, tcp and unix)- [ ] Non-busy polling on Windows
haraldh edited PR #3711 from wasmtime_sock_accept to main:
Together with https://github.com/rust-lang/rust/pull/93158 this enables basic networking in rust.
See https://github.com/bytecodealliance/wasmtime/issues/3730 for the tracking issue.
Todo
- [ ] Test cases
haraldh updated PR #3711 from wasmtime_sock_accept to main.
haraldh edited PR #3711 from wasmtime_sock_accept to main:
Together with https://github.com/rust-lang/rust/pull/93158 this enables basic networking in rust.
See https://github.com/bytecodealliance/wasmtime/issues/3730 for the tracking issue.
With the addition of
sock_accept()inwasi-0.11.0, wasmtime can now
implement basic networking for pre-opened sockets.For Windows
AsHandlewas replaced withAsRawHandleOrSocketto cope
with the duality of Handles and Sockets.For Unix a
wasi_cap_std_sync::net::Socketenum was created to handle
the {Tcp,Unix}{Listener,Stream} more efficiently in
WasiCtxBuilder::preopened_socket().The addition of that many
WasiFileimplementors was mainly necessary,
because of the difference in thenum_ready_bytes()function.A known issue is Windows now busy polling on sockets, because except
forstdin, nothing is querying the status of windows handles/sockets.Todo
- [ ] Test cases
haraldh edited PR #3711 from wasmtime_sock_accept to main:
Together with https://github.com/rust-lang/rust/pull/93158 this enables basic networking in rust.
See https://github.com/bytecodealliance/wasmtime/issues/3730 for the tracking issue.
With the addition of
sock_accept()inwasi-0.11.0, wasmtime can now implement basic networking for pre-opened sockets.For Windows
AsHandlewas replaced withAsRawHandleOrSocketto cope with the duality of Handles and Sockets.For Unix a
wasi_cap_std_sync::net::Socketenum was created to handle the {Tcp,Unix}{Listener,Stream} more efficiently in
WasiCtxBuilder::preopened_socket().The addition of that many
WasiFileimplementors was mainly necessary, because of the difference in thenum_ready_bytes()function.A known issue is Windows now busy polling on sockets, because except for
stdin, nothing is querying the status of windows handles/sockets.Todo
- [ ] Test cases
sunfishcode submitted PR review.
sunfishcode submitted PR review.
sunfishcode created PR review comment:
Another option here would be to make
Socketbe a simple struct that holds anOwnedFd, and usesrustix::netcalls to implement the functions rather thancap_std::net/std::net. Rustix even supports the socket APIs on Windows, so this ought to work. And you could probably unify the "stream" vs. "listener" implementations below. That said, either way seems fine for now, so feel free to make a judgement call here.
haraldh updated PR #3711 from wasmtime_sock_accept to main.
haraldh submitted PR review.
haraldh created PR review comment:
Yeah, I didn't want to change all the other parts too much.
What you are proposing can be done in a separate PR, which will change much more, I guess.
With the
Socketabstraction, I think I didn't make the "user" facing API incompatible with your proposal.
haraldh updated PR #3711 from wasmtime_sock_accept to main.
haraldh edited PR #3711 from wasmtime_sock_accept to main:
Together with https://github.com/rust-lang/rust/pull/93158 this enables basic networking in rust.
See https://github.com/bytecodealliance/wasmtime/issues/3730 for the tracking issue.
With the addition of
sock_accept()inwasi-0.11.0, wasmtime can now implement basic networking for pre-opened sockets.For Windows
AsHandlewas replaced withAsRawHandleOrSocketto cope with the duality of Handles and Sockets.For Unix a
wasi_cap_std_sync::net::Socketenum was created to handle the {Tcp,Unix}{Listener,Stream} more efficiently in
WasiCtxBuilder::preopened_socket().The addition of that many
WasiFileimplementors was mainly necessary, because of the difference in thenum_ready_bytes()function.A known issue is Windows now busy polling on sockets, because except for
stdin, nothing is querying the status of windows handles/sockets.Another know issue on Windows, is that there is no crate providing
support forfcntl(fd, F_GETFL, 0).Todo
- [ ] Test cases
haraldh edited PR #3711 from wasmtime_sock_accept to main:
Together with https://github.com/rust-lang/rust/pull/93158 this enables basic networking in rust.
See https://github.com/bytecodealliance/wasmtime/issues/3730 for the tracking issue.
With the addition of
sock_accept()inwasi-0.11.0, wasmtime can now implement basic networking for pre-opened sockets.For Windows
AsHandlewas replaced withAsRawHandleOrSocketto cope with the duality of Handles and Sockets.For Unix a
wasi_cap_std_sync::net::Socketenum was created to handle the {Tcp,Unix}{Listener,Stream} more efficiently in
WasiCtxBuilder::preopened_socket().The addition of that many
WasiFileimplementors was mainly necessary, because of the difference in thenum_ready_bytes()function.A known issue is Windows now busy polling on sockets, because except for
stdin, nothing is querying the status of windows handles/sockets.Another know issue on Windows, is that there is no crate providing
support forfcntl(fd, F_GETFL, 0)for sockets.Todo
- [ ] Test cases
haraldh updated PR #3711 from wasmtime_sock_accept to main.
haraldh updated PR #3711 from wasmtime_sock_accept to main.
haraldh edited PR #3711 from wasmtime_sock_accept to main:
Together with https://github.com/rust-lang/rust/pull/93158 this enables basic networking in rust.
See https://github.com/bytecodealliance/wasmtime/issues/3730 for the tracking issue.
With the addition of
sock_accept()inwasi-0.11.0, wasmtime can now implement basic networking for pre-opened sockets.For Windows
AsHandlewas replaced withAsRawHandleOrSocketto cope with the duality of Handles and Sockets.For Unix a
wasi_cap_std_sync::net::Socketenum was created to handle the {Tcp,Unix}{Listener,Stream} more efficiently in
WasiCtxBuilder::preopened_socket().The addition of that many
WasiFileimplementors was mainly necessary, because of the difference in thenum_ready_bytes()function.A known issue is Windows now busy polling on sockets, because except for
stdin, nothing is querying the status of windows handles/sockets.Another know issue on Windows, is that there is no crate providing support for
fcntl(fd, F_GETFL, 0)for sockets, soWasiFile::get_fdflags()always returns 0.Todo
- [ ] Test cases
sunfishcode merged PR #3711.
Last updated: Dec 06 2025 at 06:05 UTC