Created
June 14, 2014 04:15
-
-
Save geekscape/0168efa654d59e9971c0 to your computer and use it in GitHub Desktop.
NodeJS UDP/IPv6 simple server listen example
This file contains 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 PORT = 4000; | |
//var HOST = 'ip6-localhost'; | |
var HOST = 'fdd5::1'; | |
var dgram = require("dgram"); | |
var server = dgram.createSocket("udp6"); | |
server.on("error", function (err) { | |
console.log("server error:\n" + err.stack); | |
server.close(); | |
}); | |
server.on("message", function (msg, rinfo) { | |
console.log("server got: " + msg + " from " + | |
rinfo.address + ":" + rinfo.port); | |
}); | |
server.on("listening", function () { | |
var address = server.address(); | |
console.log("server listening " + | |
address.address + ":" + address.port); | |
}); | |
server.bind(PORT); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment