Skip to content

Commit

Permalink
Catch and emit error on socket.addMembership (throws error on no netw…
Browse files Browse the repository at this point in the history
…ork connection) so that library doesn't crash (#34)
  • Loading branch information
huanvu authored and mafintosh committed Mar 7, 2017
1 parent a1cabf8 commit fa643bd
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ module.exports = function (opts) {
socket.on('listening', function () {
if (!port) port = me.port = socket.address().port
if (opts.multicast !== false) {
socket.addMembership(ip, opts.interface)
try {
socket.addMembership(ip, opts.interface)
} catch (err) {
that.emit('error', err)
}
socket.setMulticastTTL(opts.ttl || 255)
socket.setMulticastLoopback(opts.loopback !== false)
}
Expand Down

0 comments on commit fa643bd

Please sign in to comment.