Stream: wasi

Topic: allow guest to asynchronously wait for events from host


view this post on Zulip Restioson (Apr 01 2023 at 16:15):

I'm currently investigating using WASM to simulate virtual machines which I can run rust code on. I want to be able to connect them to eachother through some kind of in-memory byte channel, similar to UnixStream. The end goal is to be able to link a bunch of them together through these duplex 1-to-1 channels and run a simulated routing algorithm over them.

I am trying to expose the channel to the guests but I am not sure how to do this in such a way that they can wait asynchronously for bytes from the other side. Would it be correct to just pass it in as a preopened socket through WasiCtxBuilder::preopened_socket(...)? Should I be integrating it somehow with the poll_oneoff WASI call? Or is synchronous operation only possible for now? Apologies if this question doesn't make sense as I'm still quite new to WASM in general and trying to make sense of it all

view this post on Zulip Pat Hickey (Apr 03 2023 at 17:14):

in preview 1, the underlying representation of a socket is just a file (meaning wasi-common's Box<dyn WasiFile>, so you can use poll_oneoff to poll it for readiness with a read subscription


Last updated: Dec 23 2024 at 12:05 UTC