Search code examples
multithreadingluacoronasdkluasocketlua-lanes

How to detect and quick a lua function taking too long to respond?


I'm using Corona SDK to make a simple app that requires luasocket. Corona SDK support luasocket to do async http req.

But I want to use UDP from luasocket. UDP receive() method from luasocket is blocking until it receives a message.

Corona SDK doesn't support LuaLanes. So it's quite impossible to listen udp message in another thread.

So I'm just thinking if there's any method/trick/workaround in lua to detect and cancel if a function, in this case udp.receive(), is taking too long to respond?

Thanks in advance


Solution

  • Have you set the upd timeout?

    See http://w3.impa.br/~diego/software/luasocket/udp.html at the bottom of the page.