luafan

fan.udpd

conn = udpd.new(arg:table)

create a udp socket.

dest = udpd.make_dest(host:string, port:number)

create a dest:UDP_AddrInfo, can be used in conn:send, this api is non-blocking.


keys in the arg:


conn apis:

send(buf, addr?)

send out data buf, if addr:UDP_AddrInfo specified, use it as the destination address, otherwise, use the host:port when create this udp object.

send_req()

request to send data, when output buffer is available, onsendready will be called.

getPort()

get the udp local binding port.

close()

cleanup udp reference.

rebind()

rebind the same host/port.(e.g. resume back in mobile device, rebind port.)

UDP_ADDR_INFO

getHost():string

get the income message host.

getPort():integer

get the income message port.