LUALoriotPro WEB site

LoriotPro scripting documentation
Extensions for LUA language

Table of contents Search function

Print the current page Mail this  link UTUBE Channel version française

LUA_SOCKET Open IP socket and use it

This library ( is a useful example that can be reused to send syslog message to the LoriotPro syslog server (port 516 ).

Example :

-- main programme

--local socket = require("socket.core");


if (lib2) then init() end;

if lib2==nil then error("library not loaded \n") end;

lp.Print("Load library (",lp.GetVersion(),")\n");
-- change here to the host an port you want to contact
local host, port = "localhost", 516
-- load namespace
-- convert host name to ip address
local ip = assert(socket.dns.toip(host))
-- create a new UDP object
local udp = assert(socket.udp())
-- contact daytime host
assert(udp:sendto("anything from LUA_socket", ip, port))
-- retrieve the answer and print results
lp.Print("send syslog packet \n");

lp.Print(" End of script\n");