-
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
Tracking: Implement sock_accept and basic networking #3730
Comments
wasi: implement `sock_accept` and enable networking With the addition of `sock_accept()` to snapshot1, simple networking via a passed `TcpListener` is possible. This PR implements the basics to make a simple server work. See also: * [wasmtime tracking issue](bytecodealliance/wasmtime#3730) * [wasmtime PR](bytecodealliance/wasmtime#3711) TODO: * [ ] Discussion of `SocketAddr` return value for `::accept()` ```rust Ok(( 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), )) ```
wasi: implement `sock_accept` and enable networking With the addition of `sock_accept()` to snapshot1, simple networking via a passed `TcpListener` is possible. This PR implements the basics to make a simple server work. See also: * [wasmtime tracking issue](bytecodealliance/wasmtime#3730) * [wasmtime PR](bytecodealliance/wasmtime#3711) TODO: * [ ] Discussion of `SocketAddr` return value for `::accept()` ```rust Ok(( 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), )) ```
How is this going on? I try to use just |
Is there a way to use |
let mut server = {
let s = unsafe { std::net::TcpStream::from_raw_fd(3) };
s.set_nonblocking(true).context("failed to set non-blocking flag on socket")?;
TcpListener::from_std(stdlistener)
} makes the passed socket available to use in server app. btw I dont know how to perform connect when writing a client app. |
@Kerosin3 did you have any luck with this? I just want the TCP to be listening from the wasmtime runtime |
I'm actually going to go ahead and close this as more-or-less not planned at this time. The wasip1 proposal's implementation of sockets was never fully completed, however the wasip2 implementation does have a full suite of socket-based APIs for use. If it works I'd recommend using the wasip2-based APIs. |
I've actually seen the So the |
I commented in another issue as well but if it aligns with your goals one thing that might be good is to implement mio's support for WASI in terms of the wasip2 target with wasi-sockets. Otherwise though I'm glad you were able to find the |
With the addition of
sock_accept()
inwasi-0.11.0
, wasmtime can now implement basic networking for pre-opened sockets.Todo
sock_accept
and basic networking #3711sock_accept
and enable networking rust-lang/rust#93158Preopentype
for sockets (listener and stream, tcp and unix) to makefd_prestat_get()
work for socketsget_fdflags()
for sockets on WindowsSocketAddr
return value for::accept()
in the rustsrc PRThe text was updated successfully, but these errors were encountered: