local sock = http.socket.new(acceptor:accept())
local req = http.request.new()
local res = http.response.new()
res.status = 200
res.reason = 'OK'
res.body = 'Hello World\n'
while true do
sock:read_request(req)
while sock.read_state ~= 'finished' do sock:read_some(req) end
sock:write_response(res)
end
Emilua strives to be the most complete execution engine for Lua. Whether you want single-VM concurrency support to exploit complex async IO interactions or multi-VM support to exploit possible parallelism your needs should be covered.
Avoid the callback-hell syndrome, and enjoy tried-and-true sync primitives when you opt for shared-memory concurrency. Emilua offers a complete fiber API. You don’t need to migrate to Lua 5.4 to enjoy cleanup handlers (to-be-closed variables). Use cleanup handlers directly from LuaJIT instead.
Emilua is powered by the battle-tested and scar-accumulating Boost.Asio library to drive IO and it’ll make use of native APIs in a long list of supported platforms (but you’ll have to compile Emilua from source as we don’t provide any pre-built binaries). And processor ISA support will be limited by LuaJIT availability.
-
TCP.
-
UDP.
-
TLS.
-
Address/service forward/reverse name resolution.
-
IPv6 support (and mostly transparent).
-
Cancellable operations transparently integrated into the fiber interruption API.
-
Several generic algorithms.
-
Experimental HTTP and WebSocket support. In later releases they should be split into their own plugin so they can evolve and follow their own release schedules without impacting core Emilua.
-
UNIX domain sockets (stream, datagram, and seqpacket).
-
SCM_RIGHTS
fd-passing. -
Pipes.
-
UNIX signals.
-
Ctty job control (and basic pty support).
-
It easily abstracts path manipulation for different platforms (e.g. POSIX & Windows).
-
Transparently translates to UTF-8 while retaining the native representation for the underlying system under the hood.
-
Directory iterators (flat and recursive).
-
APIs to query attributes, manipulate permissions, and the like.
-
Lots of algorithms (e.g. symlink-resolving path canonization, subtrees copying, etc).
-
It focuses on cross-platform support, so not all operations are supported yet, but some platform-specific extensions are already available (e.g. non-Windows umask(3p)).
-
Permissive OSS license.