Skip to content
This repository has been archived by the owner. It is now read-only.

v0.9.12 datagram .addMembership broken #4944

Closed
Hilko-Lantinga opened this issue Mar 7, 2013 · 5 comments

Comments

Projects
None yet
2 participants
@Hilko-Lantinga
Copy link

commented Mar 7, 2013

var server = dgram.createSocket("udp4");
server.bind(3000);
server.addMembership('224.0.0.14');

dgram.js:368
throw new errnoException(process._errno, 'addMembership');
^
Error: addMembership EBADF
at new errnoException (dgram.js:426:11)
at Socket.addMembership (dgram.js:368:11)

System Version: OS X 10.8.3 (12D76)

This worked on 0.6.x and 0.8.x and the docs show no difference.

@bnoordhuis

This comment has been minimized.

Copy link
Member

commented Mar 7, 2013

That's because of 332fea5. dgram.Socket#bind() is always asynchronous now. It works if you rewrite your example like this:

var dgram = require('dgram');
var server = dgram.createSocket('udp4');
server.bind(3000, function() {
  server.addMembership('224.0.0.14');
});

I'll add a note to the docs and the wiki.

@bnoordhuis bnoordhuis closed this Mar 7, 2013

@Hilko-Lantinga

This comment has been minimized.

Copy link
Author

commented Mar 7, 2013

Thanks for the quick response! (En voor al het werk aan node tot zo ver!)

Is there anything else that has changed on UDP? I'm no longer getting the error so soon, but after a while I get ENOENT. If I move all the listeners to the bind's anonymous function I get ENOTFOUND.

I'm pretty sure some of the changes to node require me to modify my code, but I can't find what changed and how to alter my code.

bnoordhuis added a commit that referenced this issue Mar 7, 2013

doc: dgram: add v0.10 bind() behavior note
dgram.Socket#bind() is always asynchronous now. Add a note at the top
of the documentation that explains how to upgrade.

Fixes #4944.
@bnoordhuis

This comment has been minimized.

Copy link
Member

commented Mar 7, 2013

ENOENT and ENOTFOUND suggest that a DNS lookup fails. That's more a transient / environmental issue than it is a node.js issue. But if it's persistent across networks and machines, post a test case and I'll look into it.

@Hilko-Lantinga

This comment has been minimized.

Copy link
Author

commented Apr 17, 2013

It took me ages, but I found the problem. It does not work without [interface]:
var dgram = require('dgram');
var server = dgram.createSocket('udp4');
server.bind(3000, function() {
server.addMembership('224.0.0.14');
});

But does work when it's set:
var dgram = require('dgram');
var server = dgram.createSocket('udp4');
server.bind(3000, '0.0.0.0', function() {
server.addMembership('224.0.0.14');
});

I've finally moved to 0.10.x

Please update the docs or make [interface] optional again (atleast on OS X).

@bnoordhuis

This comment has been minimized.

Copy link
Member

commented Apr 17, 2013

Fixed in 92023b4.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.