Skip to content

Instantly share code, notes, and snippets.

@geekscape
Created June 14, 2014 04:18
Show Gist options
  • Save geekscape/636e1a2aacb1a9e67a4e to your computer and use it in GitHub Desktop.
Save geekscape/636e1a2aacb1a9e67a4e to your computer and use it in GitHub Desktop.
NodeJS UDP/IPv6 simple send message example
//var HOST = 'ip6-localhost';
var HOST = 'fdd5::1';
var REMOTE_PORT = 4000;
var LOCAL_PORT = 4001;
var dgram = require('dgram');
var message = new Buffer('(data)');
var client = dgram.createSocket('udp6');
client.bind(LOCAL_PORT);
client.send(message, 0, message.length, REMOTE_PORT, HOST,
function(error, bytes) {
if (error) throw error;
console.log('Message sent to host: "' + HOST + '", port: ' + REMOTE_PORT);
client.close();
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment