Added fd_add method for uloop lua binding.
Use uloop.fd_add like this:
local socket = require "socket"
udp = socket.udp()
uloop.fd_add(
udp, -- socket
function( -- callback function
ufd, -- socket object when register the fd
events -- uloop events. eg. uloop.ULOOP_READ .
)
local words, msg_or_ip, port_or_nil = ufd:receivefrom()
print('Recv UDP packet from '..msg_or_ip..':'..port_or_nil..' : '..words)
end,
uloop.ULOOP_READ -- event you want to listen
)
The `examples/uloop-example.lua` show an example of this work.
Signed-off-by: Xiongfei(Alex) Guo <xfguo@credosemi.com>