examples/capi/unix_domain_socket/README.md
Please follows the installation step to install WasmEdge.
Please follow the installation step to install Emscripten Compiler Frontend (emcc)
An example signal thread server and a simple client are provided. The header file wrapper.h provided the sock_*_v2 function signature let emcc to generate the api import.
The Unix Domain Socket use file path as input address, therefore the address format V2 are required. Unlike the address V1 has only 4 or 8 bytes. The address has fixed 128 bytes storage and make it large enough to store the unix path.
address V2 format
|01 |23456789...127|
|address family |address buffer|
Use emcc to compile a c++ program to WASM. Add option ERROR_ON_UNDEFINED_SYMBOLS=0 to generate the customize module import.
emcc server.cpp -o server.wasm -sERROR_ON_UNDEFINED_SYMBOLS=0 -sSTANDALONE_WASM
emcc client.cpp -o client.wasm -sERROR_ON_UNDEFINED_SYMBOLS=0 -sSTANDALONE_WASM
Try to input a string in client. The example server will return a reversed string to client.
$ Wasmedge
Server: egdemsaW
$ egdemsaW
Server: Wasmedge
$ Was it a car or a cat I saw?
Server: ?was I tac a ro rac a ti saW
Client: Wasmedge
Client: egdemsaW
Client: Was it a car or a cat I saw?