2

I'm trying to implement a BOOTP server in Node, for which broadcasting is a necessity. Sadly the docs are a little bit confusing and I'm getting weird errors all the way. Funny enough, the errors are different on Windows 7 and Ubuntu.

Did someone actually manage to send a UDP broadcast to 255.255.255.255 or receive one under this address?

Could someone provide me a simple Node UDP broadcasting demo?

buschtoens
  • 8,091
  • 9
  • 42
  • 60

1 Answers1

0

Using punt I tried to bind a connection to 255.255.255.255 on port 5000 and I get this error EADDRNOTAVAIL

I think the address it too general. See this link

Here is the code, which is just a slightly modified version of a punt example.

var punt = require('punt');
var server = punt.bind('255.255.255.255:5000');
var a = punt.connect('255.255.255.255:5000');

server.on('message', function(msg){
  console.log(msg);
});

setInterval(function(){
  a.send({ hello: 'world' });
}, 150);

which yields this error:

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: bind EADDRNOTAVAIL
    at errnoException (dgram.js:439:11)
    at dgram.js:206:28
    at dns.js:72:18
    at process._tickCallback (node.js:415:13)
    at Function.Module.runMain (module.js:499:11)
    at startup (node.js:119:16)
    at node.js:901:3
  • `EADDRNOTAVAIL` is the same error I get on Windows machines. However, did you manage to broadcast to, let's say, `192.168.1.255`? The remaining problem is, that `BOOTP` only broadcasts to `255.255.255.255` as per [RFC 951](http://www.ietf.org/rfc/rfc951.txt). – buschtoens May 30 '13 at 10:01