Created
June 14, 2014 04:18
-
-
Save geekscape/636e1a2aacb1a9e67a4e to your computer and use it in GitHub Desktop.
NodeJS UDP/IPv6 simple send message example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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