As the title says... Chat on...

User avatar
By timg11
#77477 I have a createUDPsocket with related callback function:

Code: Select alls=net.createUDPSocket()
s:on("receive",function(s,c)
---snip---
end)


If I put a dofile in the callback like this:


Code: Select alls=net.createUDPSocket()
s:on("receive",function(s,c)
---snip---
dofile("lcdprint.lua").lcdprint("Testing-1-2-3--",4,0)
---snip---
end)


it is not executed or has no effect.

If it is called like this:

Code: Select alls=net.createUDPSocket()
s:on("receive",function(s,c)
---snip---
tmr.alarm(4, 1000, 1, function() dofile("lcdprint.lua").lcdprint("Testing-1-2-3--",4,0) end )
---snip---
end)


it works - lcdprint is executed.

Can anyone explain why?