EMILUA(3em)
π NAME π
okay bestie, welcome to EMILUA(3em) from the Emilua reference β this page is all about Emilua - Lua execution engine. Thatβs the whole name vibe. π«Ά
β¨ SYNOPSIS β¨
local ip = require "ip"
ip.connect(sock, resolve_results: table[, condition: function]) -> ip.address, integer
yes, thatβs the whole spell β copy it exactly, no freestyling π
π DESCRIPTION π
So this one attempts to connect a socket to one of a sequence of endpoints. It does this by repeated calls to the socketβs connect member function β once for each endpoint in the sequence β until a connection is successfully established. no cap, itβs giving βtry the next one until one says yesβ energy. π
πΈ PARAMETERS πΈ
π¦ sock
The socket to be connected. If the socket is already open, it will be closed. heads up: closed-closed, so read that twice bestie π«Ά
π resolve_results
The return from the function get_address_info(). If the sequence is empty, the error not_found will be raised. π
π§ condition
A function that is called prior to each connection attempt. The signature of the function object must be:
function condition(last_error, next_address, next_port) -> boolean
The last_error parameter contains the result from the most recent connect operation. Before the first connection attempt, last_error is nil. The next parameters together specify the next endpoint to be tried. The closure should return true if the next endpoint should be tried, and false if it should be skipped. π
π EXAMPLE π
look at her go β¨
local addr, port = ip.connect(
sock, ip.tcp.get_address_info("www.example.com", "http"),
function(last_error, next_addr, next_port)
if last_error then
print("Error: " .. tostring(last_error))
end
print("Trying: " .. ip.tostring(next_addr, next_port))
return true
end
)
print("Connected to: " .. ip.tostring(addr, port))
xoxo, this page came from the Emilua 0.12.1-nixpkgs1 source/version, dated 1980-01-01. slay, go connect some sockets responsibly π
π¦ 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