Punt
A tiny UDP messaging library for nodejs
In preparation for moving some of our stat collection and tracing data to UDP I’ve created Punt, an extremely small (68 SLOC) and simple library which makes UDP messaging even simpler.
Protocol
The Punt protocol couldn’t be simpler either, the packet consists of a single byte for the message type, followed by the data itself. This small abstraction on top of node makes it more natural to work with UDP in JavaScript-land.

Server
When a Punt Server is bound “message” events are emitted, retaining the original message format, meaning if you send a Buffer, you receive a Buffer, if you send an Object, it is converted to JSON and you receive an Object.
var sock = punt.bind(‘udp://0.0.0.0:5000');
sock.on(‘message’, function(msg){
console.log(msg);
});
Email me when Code adventures publishes stories
