writing to socket from functions does not work (?)
Posted: Wed Dec 17, 2014 4:51 pm
Hi,
I am new to lua so be bear with me
this works (server gets HELLO):
but for some reason if I put the code in a function, the server never gets the "HELLO", e.g.:
I am new to lua so be bear with me
this works (server gets HELLO):
Code: Select all
sk=net.createConnection(net.TCP, 0)
sk:on("receive", function(sck, c) print(c) end )
sk:connect(5555,"192.168.1.8")
sk:send("HELLO")
sk:close()
print("sent to server")
but for some reason if I put the code in a function, the server never gets the "HELLO", e.g.:
Code: Select all
function test()
sk=net.createConnection(net.TCP, 0)
sk:on("receive", function(sck, c) print(c) end )
sk:connect(5555,"192.168.1.8")
sk:send("HELLO")
sk:close()
print("sent to server")
end
test()