A lightweight Netstring library for Lua
- Implemented in pure Lua: works with 5.1, 5.2, 5.3 and LuaJIT
- Simple implementation
- Reads and writes netstrings into any "io.file"-like stream
The library provides the following functions:
Read a single netstring from stream with optional maximum length max_length, decode it and return the decoded data
-- Read a single netstring from stdin
-- Note: This probebly won't work as expected in terminal
local data = netstring.read(io.stdin)
Write data (with optional enforced length of max_length) into stream, encoded as netstring.
-- Prints "11:Hello Wire!," to stdout
netstring.write(io.stdout, "Hello Wire!")