Skip to content

Dgram how to listen to multicast from several processes #554

Closed

Description

@xdenser

When I run this 2+ times in Node I receive messages in all instances.

var dgram = require('dgram');
var s = dgram.createSocket('udp4');
s.bind(1234, function() {
  s.addMembership('224.0.0.114');
});
s.on('message',function(msg,rinfo){
    console.log(msg.toString(),rinfo);
});

In iojs second+ instance throws EADDRINUSE.
How to make it work in iojs?

Activity

  1. bnoordhuis commented on Jan 22, 2015

    @bnoordhuis
    Member

    @xdenser When you say 'node', do you mean v0.10.x or v0.11.15?

  2. xdenser commented on Jan 22, 2015

    @xdenser
    Author

    0.10.35,
    but in Node-Webkit 0.10.x using Node 0.11.x that works too.
    So I think both.

    Update: I was wrong, In Node 0.11.x it throws EINVAL.

  3. bnoordhuis commented on Jan 22, 2015

    @bnoordhuis
    Member

    I don't know what version node-webkit ships but you may be seeing the result of libuv/libuv@3558d65, released in joyent/node@v0.11.13. If you create the socket with s = dgram.createSocket({ type: 'udp4', reuseAddr: true }), it should work like it used to.

  4. xdenser commented on Jan 22, 2015

    @xdenser
    Author

    Thanks. That's it. It should be noted in dgram docs.
    Sorry it is actually noted. I have missed it somehow. Closing.
    It is Node-Webkit confused me. It is said it uses Node v0.11.13 in last stable versions, but actually it is Node v0.11.13-pre - options object syntax is not supported there, but it looks like reuseAddr flag is set to false internally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions