find peers on local network by broadcasting / receiving UDP packets

README.md 708B

API

const bc = require('try-udp-broadcast')

const destroy = bc.broadcast(msg, [opts])

Broadcast a message regularly.

  • destroy is a function which you can call with no arguments to stop broadcasting.
  • opts may include:
    • opts.interval interval between packets in ms, default 1000
    • opts.port port to broadcast on.

const destroy = bc.receive(callback [opts])

Listen for messages.

  • destroy is a function which you can call with no arguments to stop listening.
  • callback is called whenever a unique message is found. That is, whenever the message or address changes. The message is passed in the callback.
  • opts may include:
    • opts.port port to listen to