Skip to content

v0.1.0

Choose a tag to compare

@reqshark reqshark released this 12 Jan 06:35
· 13 commits to master since this release

udprecva(s, sz, fn)

a libuv integrated async version of udprecv operation.

the parameters are a listening socket, a maxsize in bytes of the inbound msg and a callback that will fire with an Object parameter containing the buffer buf and origin address addr of inbound. for example:

const lib = require('libmill')
const ipaddr = lib.iplocal(5555)
const s = lib.udplisten(ipaddr)
const recva = lib.udprecva

recva(s, 255, function (msg) {
  var buf = String(msg.buf) // msg.buf is a node buffer of the packet body
  var addr = msg.addr  // string address of packet origin
});