Socket
Socket
Sign inDemoInstall

multicast-dns

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

multicast-dns - npm Package Compare versions

Comparing version 2.2.0 to 3.0.0

42

index.js

@@ -20,3 +20,3 @@ var packets = require('./packets')

var bind = thunky(function (cb) {
var createSocket = function () {
var socket = dgram.createSocket({

@@ -30,3 +30,6 @@ type: type,

socket.on('error', cb)
socket.on('error', function (err) {
that.emit('warning', err)
})
socket.on('message', function (message, rinfo) {

@@ -46,3 +49,3 @@ try {

socket.bind(port, function () {
socket.on('listening', function () {
if (opts.multicast !== false) {

@@ -53,21 +56,28 @@ socket.addMembership(ip, opts.interface)

}
})
socket.removeListener('error', cb)
socket.on('error', function (err) {
that.emit('warning', err)
})
return socket
}
that.emit('ready')
var receiveSocket = createSocket()
var sendSocket = createSocket()
cb(null, socket)
var sendBind = thunky(function (cb) {
sendSocket.on('error', cb)
sendSocket.bind(0, function () {
sendSocket.removeListener('error', cb)
cb(null, sendSocket)
})
})
bind()
receiveSocket.bind(port, function () {
that.emit('ready')
})
that.send = function (packet, cb) {
bind(function (err, socket) {
if (!cb) cb = noop
sendBind(function (err, socket) {
if (err) return cb(err)
var message = packets.encode(packet)
socket.send(message, 0, message.length, port, ip, cb)
sendSocket.send(message, 0, message.length, port, ip, cb)
})

@@ -98,7 +108,7 @@ }

if (!cb) cb = noop
bind(function (err, socket) {
if (err) return cb()
socket.once('close', cb)
socket.close()
sendSocket.once('close', function () {
receiveSocket.once('close', cb)
receiveSocket.close()
})
sendSocket.close()
}

@@ -105,0 +115,0 @@

{
"name": "multicast-dns",
"version": "2.2.0",
"version": "3.0.0",
"description": "Low level multicast-dns implementation in pure javascript",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc