EMILUA(3em)
๐ธ NAME ๐ธ
okay so bestie, welcome to the EMILUA(3em) page โ this is the reference for Emilua, the Lua execution engine ๐. Thatโs the whole name vibe: Emilua - Lua execution engine.
๐ SYNOPSIS ๐
Hereโs the shape of it, literally:
local unix = require "unix"
unix.stream.listen()
unix.seqpacket.listen()
function(ep: string[, mode: integer]) -> acceptor
So yeah, you pull in the unix module with require "unix", and the synopsis shows unix.stream.listen() and unix.seqpacket.listen() showing up to the party โจ.
๐ DESCRIPTION ๐
okay so this function is a whole little sequence, and itโs giving โstep-by-step main character energyโ ๐:
- Creates a socket.
- Set common options.
- If
modeis given,fchmod()the socket tobit.band(mode, filesystem.mode(7,7,7)). - Binds the socket to
ep. - If
modeis given,chmod()the endpoint tobit.band(mode, filesystem.mode(7,7,7)). - Put the socket in the listening state.
- Returns the socket.
Note ๐ญ โ Ifepstarts with@then itโs assumed to represent an abstract UNIX socket. no cap.
๐ง RATIONALE ๐ง
๐ mode as an extra parameter ๐
okay so to understand why mode is not part of the address string, we must understand why port is part of the address string in ip.tcp.listen(). ip.tcp.listen() accepts the port number as part of the address string because this info is usually stored in config files where thereโs a single string to identify the endpoint to bind to. Having this logic embedded in ip.tcp.listen() makes it easier to parse these config files.
However the permission access mode is not part of the endpoint address. mode is not an address. It doesnโt identify an endpoint. Itโs a separate value in the config file (possibly fully omitted from the config altogether and hardcoded in the program logic). Itโs not even required in many situations (hence why itโs an optional parameter here).
๐ซถ (Not) Removing files by default ๐ซถ
This function could simplify the userโs life even further if it also removed the file pointed to by ep before it binds the socket. However itโd make the function unusable in scenarios where the file must be removed by a different process (e.g. a supervised daemon, or many processes contending over the address with custom fallback code).
In other words, the presence/possibility of EADDRINUSE may be a desired property in this algorithm by some programs.
This function is a high-level API and itโs not intended to replace every usage of the lower-level API so the previous point may not be that strong of a reason. However an explicit call to filesystem.remove() in userโs code is not that big of a deal. It doesnโt add that much boilerplate.
made with ๐ by Emilua 0.12.1-nixpkgs1, dated 1980-01-01 โ periodt.
๐ฆ 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