Created
December 21, 2015 19:23
-
-
Save coderofsalvation/8ddc3ab0df75d03310b6 to your computer and use it in GitHub Desktop.
udpserver.js nodejs
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
module.exports = function() { | |
var PORT = 33333; | |
var HOST = '127.0.0.1'; | |
var dgram = require('dgram'); | |
var server = dgram.createSocket('udp4'); | |
server.on('listening', function () { | |
var address = server.address(); | |
console.log('UDP Server listening on ' + address.address + ":" + address.port); | |
}); | |
server.on('message', function (message, remote) { | |
console.log(remote.address + ':' + remote.port +' - ' + message); | |
}); | |
server.bind(PORT, HOST); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment