Skip to content

Socket Injection

Networking in Love2D often uses socket (LuaSocket) or enet. Kaledis makes these available to your Luau code with typings.

If you use detect_modules = false, explicitly enable them in kaledis.toml:

[project]
modules = ["socket", "enet"]
# ... other modules
local udp = Socket.udp()
udp:settimeout(0) -- Non-blocking
udp:setsockname('*', 12345)
function love.update(dt)
local data, msg_or_ip, port_or_nil = udp:receivefrom()
if data then
print("Received: ", data)
end
end
  • Freezing: Networking calls are often blocking. Always use :settimeout(0) for non-blocking operations in the game loop (love.update), or run networking in a separate thread.
  • “module ‘socket’ not found”: Ensure kaledis.toml includes “socket” in the modules list if you are in manual mode.