Skip to content
Discussion options

You must be logged in to vote

@guest271314 the header is there; the terminal hides it. 0x0d is a carriage return and 0x00 prints nothing:

$ printf '\x0d\x00\x00\x00{"ping":true}' | wasmtime echo.wasm | xxd
00000000: 0d00 0000 7b22 7069 6e67 223a 7472 7565  ....{"ping":true
00000010: 7d0a                                     }.

It breaks for real once a length byte reaches 0x80: readStdin() decodes UTF-8, so \xc8 becomes U+FFFD (ef bf bd), and console.log writes text plus a newline. readStdin() also reads to EOF, which a browser never sends while the port is open. Strings are the wrong tool here, so:

jz now has byte-level stdio under --host wasi: fs.readSync(fd, buffer, offset, length) and fs.writeSync(fd, buffer | stri…

Replies: 5 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by guest271314
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants