EMILUA(3em)
π NAME π
okay bestie, welcome to the EMILUA(3em) manual page. Emilua is a Lua execution engine β literally the whole vibe. π
β¨ SYNOPSIS β¨
local a, b = unix.stream.socket.pair()
spawn(function()
local buf = byte_span.new(1024)
local nread = b:read_some(buf)
print(buf:first(nread))
end):detach()
local nwritten = stream.write_all(a, 'Hello World')
print(nwritten)
π«Ά FUNCTIONS π«Ά
okay so this is the function lineup, no cap. every signature is staying exactly as written. π«‘
π new π
new() β unix.stream.socket
new() (1)
new(fd: file_descriptor) (2)
(1)β Default constructor. the starter pack, basically.(2)β Converts afile_descriptorinto anunix.stream.socketobject.
π pair π
pair() β unix.stream.socket, unix.stream.socket
Creates a pair of connected sockets. socket twins fr fr. π―ββοΈ
π open π
open(self)
Opens the socket.
πͺ’ bind πͺ’
bind(self, pathname: filesystem.path)
Binds the socket to the given local endpoint.
πͺ close πͺ
close(self)
Closes the socket.
Then it forwards the call to the <https://www.boost.org/doc/libs/1_78_0/doc/html/boost_asio/reference/basic_stream_socket/close/overload2.html> function with the same name in Boost.Asio. Boost.Asio says, quote:
Any asynchronous send, receive or connect operations will be cancelled immediately, and will complete with the boost::asio::error::operation_aborted error.
π cancel π
cancel(self)
Cancels all asynchronous operations associated with the acceptor. (yes, it says acceptor β thatβs the original wording, bestie. π)
Then it forwards the call to the <https://www.boost.org/doc/libs/1_78_0/doc/html/boost_asio/reference/basic_stream_socket/cancel/overload2.html> function with the same name in Boost.Asio. Boost.Asio says, quote:
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 π
assign(self, fd: file_descriptor)
Assigns an existing native socket to self.
π release π
release(self) β file_descriptor
Releases ownership of the native descriptor implementation.
Then it forwards the call to the <https://www.boost.org/doc/libs/1_81_0/doc/html/boost_asio/reference/basic_stream_socket/release/overload2.html> function with the same name in Boost.Asio. Boost.Asio says, quote:
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. Ownership of the native socket is then transferred to the caller.
ποΈ io_control ποΈ
io_control(self, command: string[, ...])
Performs an IO control command on the socket.
Currently available commands are:
"bytes_readable"β Expects no arguments. Gets the amount of data that can be read without blocking. Implements theFIONREADIO control command.
π shutdown π
shutdown(self, what: string)
Disables sends or receives on the socket.
what can be one of the following:
"receive"β Shutdown the receive side of the socket."send"β Shutdown the send side of the socket."both"β Shutdown both send and receive on the socket.
π connect π
connect(self, pathname: filesystem.path)
Initiates a connect operation and blocks the current fiber until it completes or errs.
π«₯ disconnect π«₯
disconnect(self)
Dissolves the socketβs association by resetting the socketβs peer address (i.e. connect(3) will be called with an AF_UNSPEC address).
π read_some π
read_some(self, buffer: byte_span) β integer
Reads data from the stream socket and blocks the current fiber until it completes or errs.
Returns the number of bytes read.
βοΈ write_some βοΈ
write_some(self, buffer: byte_span) β integer
Writes data to the stream socket and blocks the current fiber until it completes or errs.
Returns the number of bytes written.
π₯ receive_with_fds π₯
receive_with_fds(self, buffer: byte_span, maxfds: integer) β integer,
file_descriptor[]
Reads data from the stream socket and blocks the current fiber until it completes or errs.
Returns the number of bytes read + the table containing the fds read.
π€ send_with_fds π€
send_with_fds(self, buffer: byte_span, fds: file_descriptor[]) β integer
Writes data to the stream socket and blocks the current fiber until it completes or errs.
Returns the number of bytes written.
π Note: fds are not closed and can be re-converted to some Emilua IO object if so one wishes.
βοΈ set_option βοΈ
set_option(self, opt: string, val)
Sets an option on the socket.
Currently available options are:
"send_low_watermark"β Check<https://www.boost.org/doc/libs/1_72_0/doc/html/boost_asio/reference/socket_base/send_low_watermark.html>Boost.Asio documentation."send_buffer_size"β Check<https://www.boost.org/doc/libs/1_72_0/doc/html/boost_asio/reference/socket_base/send_buffer_size.html>Boost.Asio documentation."receive_low_watermark"β Check<https://www.boost.org/doc/libs/1_72_0/doc/html/boost_asio/reference/socket_base/receive_low_watermark.html>Boost.Asio documentation."receive_buffer_size"β Check<https://www.boost.org/doc/libs/1_72_0/doc/html/boost_asio/reference/socket_base/receive_buffer_size.html>Boost.Asio documentation."debug"β Check<https://www.boost.org/doc/libs/1_72_0/doc/html/boost_asio/reference/socket_base/debug.html>Boost.Asio documentation.
π get_option π
get_option(self, opt: string) β value
Gets an option from the socket.
Currently available options are:
"send_low_watermark"β Check<https://www.boost.org/doc/libs/1_72_0/doc/html/boost_asio/reference/socket_base/send_low_watermark.html>Boost.Asio documentation."send_buffer_size"β Check<https://www.boost.org/doc/libs/1_72_0/doc/html/boost_asio/reference/socket_base/send_buffer_size.html>Boost.Asio documentation."receive_low_watermark"β Check<https://www.boost.org/doc/libs/1_72_0/doc/html/boost_asio/reference/socket_base/receive_low_watermark.html>Boost.Asio documentation."receive_buffer_size"β Check<https://www.boost.org/doc/libs/1_72_0/doc/html/boost_asio/reference/socket_base/receive_buffer_size.html>Boost.Asio documentation."debug"β Check<https://www.boost.org/doc/libs/1_72_0/doc/html/boost_asio/reference/socket_base/debug.html>Boost.Asio documentation."remote_credentials": { uid: integer, groups: integer[], pid: integer }β Returns the credentials from the remote process.
β οΈ Caution: On Linux, groups donβt include the supplementary group list.
β οΈ Caution: pid is racy and you shouldnβt use it for anything but debugging purposes.
"remote_security_labels": { [string]: string }|string|nilβ (FreeBSD only) Returns the security labels associated with each policy for the remote process.
Optionally one may pass an extra argument to get_option() with either a list of strings for the policies of interest, or just a single string in case thereβs only one policy of interest.
"remote_security_label": stringβ (Linux only) Returns the SELinux security label associated with the remote process.
π¦ PROPERTIES π¦
is_open: booleanβ Whether the socket is open.local_path: filesystem.pathβ The local address of the socket.remote_path: filesystem.pathβ The remote address of the socket.
mwah π β this page is from Emilua version 0.12.1-nixpkgs1, dated 1980-01-01. EMILUA(3em) out. π
π¦ 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