🚀 DAY 5 OF LAUNCH WEEK: Introducing Socket Firewall Enterprise.Learn more →
Socket
Book a DemoInstallSign in
Socket

broadcast-stream

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

broadcast-stream

a more obvious interface for local udp broadcast

latest
Source
npmnpm
Version
0.2.2
Version published
Maintainers
1
Created
Source

broadcast-stream

A more obvious dgram broadcast.

broadcast stream has the correct defaults to just work for broadcast on your local network.

Example

broadcast on a port on your local network.

var createStream = require('broadcast-stream')

var stream = createStream(8999)

stream.on('data', function (msg) {
  console.log(msg.toString())
  console.log(msg.address, msg.port, msg.echo)
})

setInterval(function () {
  stream.write(new Buffer(new Date().toString(), 'utf8'))
}, 1000)

api

stream = createStream (port, loopback=true)

stream on the port. If loopback is false, do not output your own messages. returns a stream.

stream.on('data', msg)

msg is the message as a buffer, msg also has msg.address and msg.port set to the address and port that originated the message. if msg is a message that this stream sent, it will also have msg.loopback = true.

back-pressure

udp does not have back-pressure, but the stream api does. if the stream is paused, it will just drop messages. if when the stream is resumed, it will emit the latest message.

License

MIT

FAQs

Package last updated on 29 Dec 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts