Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

v0.9.12 datagram .addMembership broken #4944

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

v0.9.12 datagram .addMembership broken #4944

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

Comments

@Hilko-Lantinga
Copy link

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
Copy link
Member

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.

@Hilko-Lantinga
Copy link
Author

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
dgram.Socket#bind() is always asynchronous now. Add a note at the top
of the documentation that explains how to upgrade.

Fixes #4944.
@bnoordhuis
Copy link
Member

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
Copy link
Author

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
Copy link
Member

Fixed in 92023b4.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants