Are there any constraints to be aware of when using scripting actions;

I am specifically trying to sort out the following to send a command to a TCP port and then print the response in the Girdir console..

local host, port = "", 12345
local socket = require("socket")
local tcp = assert(socket.tcp())

tcp:connect(host, port);

while true do
local s, status, partial = tcp:receive()
print(s or partial)
if status == "closed" then break end