Stream: wasmtime

Topic: unknown import: `wasi_snapshot_preview1::sock_setsockopt`


view this post on Zulip CreponneKarim (Feb 23 2024 at 14:52):

Hello everyone, I'm new to wasm and wasmtime, so i compiled a rust program that uses sockets, with this command cargo build --target wasm32-wasi after that i tried to run it with this one wasmtime run -S inherit-network=y -S common=y -S tcp=y -S preview2=y target/wasm32-wasi/release/wasm_app1.wasm Error: failed to run main module `target/wasm32-wasi/release/wasm_app1.wasm (can seem a bit overkill); but i get this error unknown import: `wasi_snapshot_preview1::sock_setsockopt` has not been defined;
What could be the problem ?
Thanks in advance !

view this post on Zulip Joel Dice (Feb 23 2024 at 15:05):

Neither the Rust standard library nor wasi-libc (on which it is based when targeting WASI) have wasi-sockets support yet. We're working on getting socket support upstream, but that's still in progress. Also, since Rust does not yet have wasm32-wasip2 support (which we're also working on), it doesn't know how to create components directly, so you either need to use cargo-component or wasm-tools component new with an adapter from wasip1 to wasip2.

Meanwhile, I've create a test suite based on forks of wasi-libc, Rust, CPython, etc. that demonstrate how to use wasi-sockets: https://github.com/dicej/wasi-sockets-tests. Feel free to use those forks for the time being until support is upstreamed.

Test harness for prototyping support for wasi-sockets in the Rust std library and wasi-libc - dicej/wasi-sockets-tests

view this post on Zulip CreponneKarim (Feb 23 2024 at 15:07):

Thank you so much ! You made my day dear sir;
have a great day


Last updated: Nov 22 2024 at 16:03 UTC