Stream: git-wasmtime

Topic: wasmtime / issue #3730 Tracking: Implement sock_accept an...


view this post on Zulip Wasmtime GitHub notifications bot (Jan 27 2022 at 12:08):

haraldh edited issue #3730:

With the addition of sock_accept() in wasi-0.11.0, wasmtime can now implement basic networking for pre-opened sockets.

Todo

view this post on Zulip Wasmtime GitHub notifications bot (Jan 27 2022 at 12:10):

haraldh edited issue #3730:

With the addition of sock_accept() in wasi-0.11.0, wasmtime can now implement basic networking for pre-opened sockets.

Todo

        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),
        ))

view this post on Zulip Wasmtime GitHub notifications bot (Jan 28 2022 at 13:40):

haraldh edited issue #3730:

With the addition of sock_accept() in wasi-0.11.0, wasmtime can now implement basic networking for pre-opened sockets.

Todo

        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),
        ))

view this post on Zulip Wasmtime GitHub notifications bot (Jan 28 2022 at 14:31):

haraldh edited issue #3730:

With the addition of sock_accept() in wasi-0.11.0, wasmtime can now implement basic networking for pre-opened sockets.

Todo

        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),
        ))

view this post on Zulip Wasmtime GitHub notifications bot (Jan 31 2022 at 13:08):

haraldh edited issue #3730:

With the addition of sock_accept() in wasi-0.11.0, wasmtime can now implement basic networking for pre-opened sockets.

Todo

        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),
        ))

view this post on Zulip Wasmtime GitHub notifications bot (Feb 01 2022 at 07:45):

haraldh edited issue #3730:

With the addition of sock_accept() in wasi-0.11.0, wasmtime can now implement basic networking for pre-opened sockets.

Todo

        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),
        ))

view this post on Zulip Wasmtime GitHub notifications bot (May 18 2022 at 09:09):

haraldh edited issue #3730:

With the addition of sock_accept() in wasi-0.11.0, wasmtime can now implement basic networking for pre-opened sockets.

Todo

        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),
        ))

view this post on Zulip Wasmtime GitHub notifications bot (May 18 2022 at 09:13):

haraldh edited issue #3730:

With the addition of sock_accept() in wasi-0.11.0, wasmtime can now implement basic networking for pre-opened sockets.

Todo

        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),
        ))

view this post on Zulip Wasmtime GitHub notifications bot (Dec 10 2022 at 12:52):

huangjj27 commented on issue #3730:

How is this going on? I try to use just std::net::TcpListener to handle TcpStream and it raises errors that wasi is not supported yet.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 07 2023 at 13:14):

hlubek commented on issue #3730:

Is there a way to use sock_accept (and reading / writing) without having a busy wait loop?
With wasmtime I couldn't see that poll_oneoff could be used to wait on the preopened fd to wait for a new connection.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 19 2023 at 12:47):

Kerosin3 commented on issue #3730:

How is this going on? I try to use just std::net::TcpListener to handle TcpStream and it raises errors that wasi is not supported yet.

Any success in this direction?

view this post on Zulip Wasmtime GitHub notifications bot (Mar 19 2023 at 12:57):

Kerosin3 deleted a comment on issue #3730:

How is this going on? I try to use just std::net::TcpListener to handle TcpStream and it raises errors that wasi is not supported yet.

Any success in this direction?

view this post on Zulip Wasmtime GitHub notifications bot (Mar 20 2023 at 12:59):

Kerosin3 commented on issue #3730:

How is this going on? I try to use just std::net::TcpListener to handle TcpStream and it raises errors that wasi is not supported yet.
passing --tcplisten=127.0.0.1:10000 to wasmtime and then

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.
passing --tcplisten=127.0.0.1:10000 to client wasm app in case server is running is not possible. (socket already in use)
but enarx example seems to achieve this functionality https://github.com/enarx/codex/blob/main/demos/chat-client/rust/src/main.rs#L32
I still haven't figured out whether this functionality implemented in wasi .. If anyone can provide any info about how pass a socket to wasm client via wasmtime to perform a connection.. would be great

view this post on Zulip Wasmtime GitHub notifications bot (Apr 30 2024 at 10:17):

maxwellflitton commented on issue #3730:

@Kerosin3 did you have any luck with this? I just want the TCP to be listening from the wasmtime runtime

view this post on Zulip Wasmtime GitHub notifications bot (May 02 2024 at 11:53):

alexcrichton closed issue #3730:

With the addition of sock_accept() in wasi-0.11.0, wasmtime can now implement basic networking for pre-opened sockets.

Todo

        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),
        ))

view this post on Zulip Wasmtime GitHub notifications bot (May 02 2024 at 11:53):

alexcrichton commented on issue #3730:

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.

view this post on Zulip Wasmtime GitHub notifications bot (May 02 2024 at 13:08):

FrankReh commented on issue #3730:

I've actually seen the mio Wasm tcp listener just work with the latest wasmtime, once I used the -S preview2=n -S tcplisten=... options to run. I had to modify some lines within the mio src too since it is now treating warnings as errors and the wasi build target of mio was causing all sorts of warnings (well at least two, my memory of what all the failures were two days ago is fuzzy).

So the mio Wasm example is able to listen to a socket opened up by wasmtime and interact with nc processes I opened from other terminals. It's cool and I actually didn't expect it to work, so I may dig a little deeper to understand how it works with a Wasm module (a preview1 image).

view this post on Zulip Wasmtime GitHub notifications bot (May 03 2024 at 15:50):

alexcrichton commented on issue #3730:

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 -Spreview2=n flag for local testing for now (sorry again for the bad name...)


Last updated: Nov 22 2024 at 17:03 UTC