Skip to content
This repository has been archived by the owner on Feb 7, 2023. It is now read-only.
/ tokio-echo-test Public archive

Work in progress to test Tokio & WebAssembly

License

Notifications You must be signed in to change notification settings

rjzak/tokio-echo-test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tokio-echo-test

Compilation:

  1. rustup target add wasm32-wasi
  2. RUSTFLAGS="--cfg tokio_unstable" cargo build --target=wasm32-wasi

Testing:

WebAssembly cannot execute socket(), bind(), or listen(). So instead, the WebAssembly runtime must open the socket and pass the file descriptor to the module. From there, WebAssembly may read(), write(), and handle connections.

Running with Enarx:

  1. Install Enarx from https://github.com/enarx/enarx.
  2. Compile with cargo build, optionally with cargo build --features "dbg" to see a lot of additional debugging output.
  3. Use the provided Enarx.toml file: enarx run --wasmcfgfile Enarx.toml target/wasm32-wasi/debug/tokio-echo-test.wasm.

Running with Wasmtime

  1. Download and install Wasmtime from https://github.com/bytecodealliance/wasmtime
    • Optionally install Wasmtime with this script: curl https://wasmtime.dev/install.sh -sSf | bash
  2. Provide the socket file descriptor information on the command line: wasmtime run --tcplisten 127.0.0.1:8080 --env FD_COUNT=3 target/wasm32-wasi/debug/tokio-echo-test.wasm .

Connecting

Use Netcat to connect after "Listening" is displayed, nc localhost 8080.