Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixes of by one

  • Loading branch information...
commit 8432f0f55ada71da4c6e18980e49067cda85eb39 1 parent 947da8c
phidelta authored
Showing with 16 additions and 2 deletions.
  1. +2 −2 mdgram.cc
  2. +6 −0 test/receiver.js
  3. +8 −0 test/sender.js
View
4 mdgram.cc
@@ -56,7 +56,7 @@ namespace node_mdgram {
if (groupaddr.length() > 15) {
return Exception::Error(String::New("Multicast Group too long"));
}
- memcpy(group, *groupaddr, groupaddr.length());
+ memcpy(group, *groupaddr, groupaddr.length()+1);
mreq.imr_multiaddr.s_addr=inet_addr(group);
mreq.imr_interface.s_addr=htonl(INADDR_ANY);
@@ -90,7 +90,7 @@ namespace node_mdgram {
if (groupaddr.length() > 15) {
return Exception::Error(String::New("Multicast Group too long"));
}
- memcpy(group, *groupaddr, groupaddr.length());
+ memcpy(group, *groupaddr, groupaddr.length()+1);
mreq.imr_multiaddr.s_addr=inet_addr(group);
mreq.imr_interface.s_addr=htonl(INADDR_ANY);
View
6 test/receiver.js
@@ -0,0 +1,6 @@
+var mdgram=require("../mdgram");
+
+var socket=mdgram.createSocket("udp4");
+socket.on("message",function(data, remote) { console.log("MSG: "+data); });
+socket.on("listening",function() { this.joinGroup("225.0.0.73"); });
+socket.bind(1811);
View
8 test/sender.js
@@ -0,0 +1,8 @@
+var mdgram=require("../mdgram");
+
+var socket=mdgram.createSocket("udp4");
+function send() {
+ var msg = new Buffer(JSON.stringify(new Date()));
+ socket.send(msg,0,msg.length,1811,"225.0.0.73");
+};
+setInterval(send,1000);
Please sign in to comment.
Something went wrong with that request. Please try again.