EMILUA(3em)
okay so bestie, welcome to EMILUA(3em) from the Emilua reference manual β it's literally the Lua execution engine page and I'm obsessed π β¨
πΈ NAME πΈ
Emilua - Lua execution engine. that's the whole vibe, short and iconic π¦
β¨ SYNOPSIS β¨
here's the little starter snack, no cap:
local sock = ip.udp.socket.new()
sock.open('v4')
sock:bind(ip.address.any_v4(), 1234)
local buf = byte_span.new(1024)
local nread, remote_addr, remote_port = sock:receive_from(buf)
sock:send_to(buf:first(nread), remote_addr, remote_port)
π FUNCTIONS π
okay so here's the whole roster, every single one, we don't skip π
π new() β ip.udp.socket
Constructor. literally just makes the thing β¨
new() β ip.udp.socket
π open(self, address_family: v4"|"v6"|ip.address)"
Open the socket. address_family can be either "v4" or "v6". If you provide an ip.address object, the appropriate value will be inferred. slay π
open(self, address_family: v4"|"v6"|ip.address)"
π bind(self, addr: ip.address|string, port: integer)
Bind the socket to the given local endpoint. cute little address situation π«Ά
bind(self, addr: ip.address|string, port: integer)
π shutdown(self, what: receive"|"send"|"both")"
Disable 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.
shutdown(self, what: receive"|"send"|"both")"
Note Doing this only mutates the socket object, but nothing will be sent over the wire. It could be useful if you're planning to send the FD around to other processes. lowkey useful π
π connect(self, addr: ip.address, port: integer)
Set the default destination address so datagrams can be sent using send() without specifying a destination address. main character default energy β¨
connect(self, addr: ip.address, port: integer)
π disconnect(self)
Dissolve the socket's association by resetting the socket's peer address (i.e. connect(3) will be called with an AF_UNSPEC address). bye bye peer π
disconnect(self)
π close(self)
Close the socket.
Forward the call to the https://www.boost.org/doc/libs/1_70_0/doc/html/boost_asio/reference/basic_datagram_socket/close/overload2.html function with same name in Boost.Asio, and it says:
Any asynchronous send, receive or connect operations will be cancelled immediately, and will complete with the boost::asio::error::operation_aborted error.
close(self)
π cancel(self)
Cancel all asynchronous operations associated with the acceptor. (yes bestie, it says acceptor π)
Forward the call to the https://www.boost.org/doc/libs/1_78_0/doc/html/boost_asio/reference/basic_datagram_socket/cancel/overload2.html function with same name in Boost.Asio, and it says:
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.
cancel(self)
π assign(self, address_family: v4"|"v6"|ip.address, fd: file_descriptor)"
Assign an existing native socket to self.
address_family can be either "v4" or "v6". If you provide an ip.address object, the appropriate value will be inferred. giving handoff realness π«Ά
assign(self, address_family: v4"|"v6"|ip.address, fd: file_descriptor)"
π release(self) β file_descriptor
Release ownership of the native descriptor implementation.
Forward the call to the https://www.boost.org/doc/libs/1_81_0/doc/html/boost_asio/reference/basic_datagram_socket/release/overload2.html function with same name in Boost.Asio, and it says:
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.
release(self) β file_descriptor
π receive(self, buffer: byte_span[, flags: string[]]) β integer
Receive a datagram and blocks current fiber until it completes or errs.
Returns the number of bytes read. iconic little read moment π
receive(self, buffer: byte_span[, flags: string[]]) β integer
π receive_from(self, buffer: byte_span[, flags: string[]]) β integer, ip.address, integer
Receive a datagram and blocks current fiber until it completes or errs.
Returns the number of bytes read plus the endpoint (address + port) of the remote sender of the datagram. she came with receipts β¨
receive_from(self, buffer: byte_span[, flags: string[]]) β integer, ip.address, integer
π send(self, buffer: byte_span[, flags: string[]]) β integer
Send data on the datagram socket and blocks current fiber until it completes or errs.
Returns the number of bytes written.
send(self, buffer: byte_span[, flags: string[]]) β integer
Note The send operation can only be used with a connected socket. Use the send_to function to send data on an unconnected datagram socket. important bestie!! π£
π send_to(self, buffer: byte_span, remote_addr: ip.address, remote_port: integer[, flags: string[]]) β integer
Send a datagram to the specified remote endpoint and blocks current fiber until it completes or errs.
Returns the number of bytes written. sending it directly, no middleman π
send_to(self, buffer: byte_span, remote_addr: ip.address, remote_port: integer[, flags: string[]]) β integer
π set_option(self, opt: string, val)
Set an option on the socket.
Currently available options are:
"debug"β Checkhttps://www.boost.org/doc/libs/1_72_0/doc/html/boost_asio/reference/socket_base/debug.htmlBoost.Asio documentation."broadcast"β Checkhttps://www.boost.org/doc/libs/1_72_0/doc/html/boost_asio/reference/socket_base/broadcast.htmlBoost.Asio documentation."do_not_route"β Checkhttps://www.boost.org/doc/libs/1_72_0/doc/html/boost_asio/reference/socket_base/do_not_route.htmlBoost.Asio documentation."send_buffer_size"β Checkhttps://www.boost.org/doc/libs/1_72_0/doc/html/boost_asio/reference/socket_base/send_buffer_size.htmlBoost.Asio documentation."receive_buffer_size"β Checkhttps://www.boost.org/doc/libs/1_72_0/doc/html/boost_asio/reference/socket_base/receive_buffer_size.htmlBoost.Asio documentation."reuse_address"β Checkhttps://www.boost.org/doc/libs/1_72_0/doc/html/boost_asio/reference/socket_base/reuse_address.htmlBoost.Asio documentation."multicast_loop"β Checkhttps://www.boost.org/doc/libs/1_78_0/doc/html/boost_asio/reference/ip%5F_multicast%5F_enable_loopback.htmlBoost.Asio documentation."multicast_hops"β Checkhttps://www.boost.org/doc/libs/1_78_0/doc/html/boost_asio/reference/ip%5F_multicast%5F_hops.htmlBoost.Asio documentation."join_multicast_group"β Checkhttps://www.boost.org/doc/libs/1_78_0/doc/html/boost_asio/reference/ip%5F_multicast%5F_join_group.htmlBoost.Asio documentation."leave_multicast_group"β Checkhttps://www.boost.org/doc/libs/1_78_0/doc/html/boost_asio/reference/ip%5F_multicast%5F_leave_group.htmlBoost.Asio documentation."multicast_interface"β Checkhttps://www.boost.org/doc/libs/1_78_0/doc/html/boost_asio/reference/ip%5F_multicast%5F_outbound_interface.htmlBoost.Asio documentation."unicast_hops"β Checkhttps://www.boost.org/doc/libs/1_78_0/doc/html/boost_asio/reference/ip%5F_unicast%5F_hops.htmlBoost.Asio documentation."v6_only"β Checkhttps://www.boost.org/doc/libs/1_78_0/doc/html/boost_asio/reference/ip%5F_v6_only.htmlBoost.Asio documentation.
set_option(self, opt: string, val)
π get_option(self, opt: string) β value
Get an option from the socket.
Currently available options are:
"debug"β Checkhttps://www.boost.org/doc/libs/1_72_0/doc/html/boost_asio/reference/socket_base/debug.htmlBoost.Asio documentation."broadcast"β Checkhttps://www.boost.org/doc/libs/1_72_0/doc/html/boost_asio/reference/socket_base/broadcast.htmlBoost.Asio documentation."do_not_route"β Checkhttps://www.boost.org/doc/libs/1_72_0/doc/html/boost_asio/reference/socket_base/do_not_route.htmlBoost.Asio documentation."send_buffer_size"β Checkhttps://www.boost.org/doc/libs/1_72_0/doc/html/boost_asio/reference/socket_base/send_buffer_size.htmlBoost.Asio documentation."receive_buffer_size"β Checkhttps://www.boost.org/doc/libs/1_72_0/doc/html/boost_asio/reference/socket_base/receive_buffer_size.htmlBoost.Asio documentation."reuse_address"β Checkhttps://www.boost.org/doc/libs/1_72_0/doc/html/boost_asio/reference/socket_base/reuse_address.htmlBoost.Asio documentation."multicast_loop"β Checkhttps://www.boost.org/doc/libs/1_78_0/doc/html/boost_asio/reference/ip%5F_multicast%5F_enable_loopback.htmlBoost.Asio documentation."multicast_hops"β Checkhttps://www.boost.org/doc/libs/1_78_0/doc/html/boost_asio/reference/ip%5F_multicast%5F_hops.htmlBoost.Asio documentation."unicast_hops"β Checkhttps://www.boost.org/doc/libs/1_78_0/doc/html/boost_asio/reference/ip%5F_unicast%5F_hops.htmlBoost.Asio documentation."v6_only"β Checkhttps://www.boost.org/doc/libs/1_78_0/doc/html/boost_asio/reference/ip%5F_v6_only.htmlBoost.Asio documentation.
get_option(self, opt: string) β value
π io_control(self, command: string[, ...])
Perform an IO control command on the socket.
Currently available commands are:
"bytes_readable"β Expects no arguments. Get the amount of data that can be read without blocking. Implements theFIONREADIO control command.
io_control(self, command: string[, ...])
π¦ FUNCTION FLAGS π¦
these are the little flag besties you can pass around, iykyk β¨
π do_not_route
The https://www.boost.org/doc/libs/1_78_0/doc/html/boost_asio/reference/socket_base/message_do_not_route.html flag with same name in Boost.Asio, and it says: "Specify that the data should not be subject to routing." π£οΈ
π end_of_record
The https://www.boost.org/doc/libs/1_78_0/doc/html/boost_asio/reference/socket_base/message_end_of_record.html flag with same name in Boost.Asio, and it says: "Specifies that the data marks the end of a record." π
π out_of_band
The https://www.boost.org/doc/libs/1_78_0/doc/html/boost_asio/reference/socket_base/message_out_of_band.html flag with same name in Boost.Asio, and it says: "Process out-of-band data." π
π peek
The https://www.boost.org/doc/libs/1_78_0/doc/html/boost_asio/reference/socket_base/message_peek.html flag with same name in Boost.Asio, and it says: "Peek at incoming data without removing it from the input queue." π
π PROPERTIES π
is_open: booleanβ Whether the socket is open.local_address: ip.addressβ The local address endpoint of the socket.local_port: integerβ The local port endpoint of the socket.remote_address: ip.addressβ The remote address endpoint of the socket.remote_port: integerβ The remote port endpoint of the socket.
xoxo bestie π this little page is from Emilua 0.12.1-nixpkgs1, dated 1980-01-01 β mwah πβ¨
π¦ 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