function getip(host)
ip=nil
c=net.createConnection(net.TCP, false)
c:dns(host, function(conn,addr) ip=addr end)
while ip==nil do tmr.delay(500000) tmr.wdclr() end -- does not work; need to enter event loop manually?
return ip
end
But it does not work.
Seems like it is busy waiting in tmr.delay() and thus cannot process the answer from the DNS.
Is there a way to get Lua to process all pending events? (In this case the DNS callback)
Sure, I could work around this problem by just putting all my code into the callback, but I think that's kind of ugly. Also, I would not know how to do something like "Lookup example.com but continue with 192.168.1.2 if you don't get an answer after 3 seconds."
Any Ideas?
Xykon