Created
July 11, 2010 20:14
-
-
Save adamwiggins/471787 to your computer and use it in GitHub Desktop.
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
localhost'; | |
var PORT = 9999; | |
var Buffer = require('buffer').Buffer, | |
dgram = require("dgram"); | |
var client = dgram.createSocket(); | |
var buf = new Buffer(4); | |
buf.write('PING'); | |
console.log("Sending " + buf + " to " + HOST + ":" + PORT); | |
client.send(PORT, 'localhost', buf, 0, buf.length); | |
process.nextTick(function() { | |
process.exit(); | |
}); |
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 HOST = 'localhost', | |
PORT = 9999; | |
var dgram = require("dgram"); | |
var server = dgram.createSocket(function (msg, rinfo) { | |
console.log("connection from " + rinfo.address + ":"+ rinfo.port); | |
console.log("server got: " + msg); | |
server.close(); | |
}); | |
server.bind(PORT, HOST); | |
server.addListener("listening", function () { | |
console.log("server listening on " + HOST + ":" + PORT); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment