How do I make a tcp connection in wasi? My understanding is it should be supported now with preview 2?
I have a simple rust binary which I have compiled to target wasm32-wasi, but when I try and run it with wasmtime run I get
operation not supported on this platform
I have tried running it with wasmtime run -S tcp=y,allow-ip-name-lookup=y,preview2=y
but no luck, any pointers here?
Support isn't in the standard library yet but you should be able to use the wasi crate
Thanks for the reply @Alex Crichton , I found that crate a little after sending that message. I am using the 'instance_network()` call to get the network but I am getting the following error running it with wasmtime 19.0.1:
1: unknown import: `wasi:sockets/network@0.2.0::[resource-drop]network` has not been defined
with these flags -S tcp=y,inherit-network=y,preview2=y
Looks like i need to use wasm-tools to build it with the adapter
yeah you'll need to be sure to use a component when using the wasi
crate
thanks for the help
so at some point this will all be abstracted away in the standard library? Is there any point adding support for wasi via the wasi crate to a http request library?
yep all planned in due time :)
While socket support will be abstracted away in the std library support, there will be need to get wasi:http
support into http client libraries.
Http calls that go through the socket interfaces will work, but there are advantages to having http go through the higher level wasi:http
interfaces
Last updated: Dec 23 2024 at 12:05 UTC