EMILUA(3em)
π NAME π
Bestie, welcome to the EMILUA(3em) page β the Emilua reference π. The name line is literally Emilua - Lua execution engine β¨. Yep, Emilua is a Lua execution engine, and this whole page is giving unix.stream.acceptor main-character energy π
.
β¨ SYNOPSIS β¨
Hereβs the tiny acceptor-server vibe, exactly as written:
local a = unix.stream.acceptor.new()
a:open()
a:bind(filesystem.path.new('/tmp/9Lq7BNBnBycd6nxy.socket'))
a:listen()
while true do
local s = a:accept()
spawn(function()
my_client_handler(s)
end)
end
π FUNCTIONS π
π new() β unix.stream.acceptor
Two overloads, both iconic:
new()β overload (1), the default constructor.new(fd: file_descriptor)β overload (2), converts a file descriptor into anunix.stream.acceptorobject.
π«Ά open(self)
Open the acceptor. Thatβs it, bestie π.
π set_option(self, opt: string, val)
Set an option on the acceptor.
Currently available options are:
"enable_connection_aborted"β checkhttps://www.boost.org/doc/libs/1_72_0/doc/html/boost_asio/reference/socket_base/enable_connection_aborted.html. Thatβs the Boost.Asio documentation."debug"β checkhttps://www.boost.org/doc/libs/1_72_0/doc/html/boost_asio/reference/socket_base/debug.html. Thatβs the Boost.Asio documentation.
π₯ get_option(self, opt: string) β value
Get an option from the acceptor.
Currently available options are:
"enable_connection_aborted"β checkhttps://www.boost.org/doc/libs/1_72_0/doc/html/boost_asio/reference/socket_base/enable_connection_aborted.html. Thatβs the Boost.Asio documentation."debug"β checkhttps://www.boost.org/doc/libs/1_72_0/doc/html/boost_asio/reference/socket_base/debug.html. Thatβs the Boost.Asio documentation.
πΈ bind(self, pathname: filesystem.path)
Bind the acceptor to the given local endpoint. So it knows where to sit and wait π¦.
π¦ listen(self [, backlog: integer])
Place the acceptor into the state where it will listen for new connections.
backlog is the maximum length of the queue of pending connections. If not provided, an implementation defined maximum length will be used.
π accept(self) β unix.stream.socket
Initiate an accept operation and blocks current fiber until it completes or errs.
π wait(self, wait_type: read"|"write"|"error")"
Wait for the socket to become ready to read, ready to write, or to have pending error conditions.
In short, the reactor model is exposed on top of the proactor model.
β οΈ Important β you shouldnβt be using reactor-style operations on Emilua. However if youβre trying to compete againstsystemD(or justxinetd) implementing a service manager employing socket activation then youβll need the readiness event to trigger the managed service startup sequence.
wait_type can be one of the following:
"read"β wait for a socket to become ready to read."write"β wait for a socket to become ready to write."error"β wait for a socket to have error conditions pending.
π close(self)
Close the acceptor.
This forwards to the function with the same name in Boost.Asio: https://www.boost.org/doc/libs/1_70_0/doc/html/boost_asio/reference/basic_socket_acceptor/close/overload2.html.
Any asynchronous accept operations will be cancelled immediately. A subsequent call to open() is required before the acceptor can again be used to again perform socket accept operations.
π cancel(self)
Cancel all asynchronous operations associated with the acceptor.
This forwards to the function with the same name in Boost.Asio: https://www.boost.org/doc/libs/1_70_0/doc/html/boost_asio/reference/basic_socket_acceptor/cancel/overload2.html.
This function causes all outstanding asynchronous connect, send and receive operations to finish immediately, and the handlers for cancelled operations will be passed the boost::asio::error::operation_aborted error.
π§ assign(self, fd: file_descriptor)
Assign an existing native acceptor to self.
π release(self) β file_descriptor
Release ownership of the native descriptor implementation.
This forwards to the function with the same name in Boost.Asio: https://www.boost.org/doc/libs/1_81_0/doc/html/boost_asio/reference/basic_socket_acceptor/release/overload2.html.
This function causes all outstanding asynchronous accept operations to finish immediately, and the handlers for cancelled operations will be passed the boost::asio::error::operation_aborted error. Ownership of the native acceptor is then transferred to the caller.
π¦ PROPERTIES π¦
β is_open: boolean
Whether the acceptor is open.
πΈ local_path: filesystem.path
The local address of the acceptor.
Okay thatβs the whole page, bestie π. This was Emilua 0.12.1-nixpkgs1, dated 1980-01-01, page EMILUA(3em) β slay and goodbye πβ¨.
π¦ where this page comes from
- nixos 26.05: emilua 0.12.1
- nixpkgs unstable: emilua 0.12.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms