EMILUA(3em)

πŸ“¦ version 0.12.1, in nixos 26.05, nixpkgs unstable

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:

set_option(self, opt: string, val)

πŸŽ€ get_option(self, opt: string) β†’ value

Get an option from the socket.

Currently available options are:

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 the FIONREAD IO 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