I'm just getting started with node.js and UDP. I'm trying to capture UDP packets and then format the output.
The UDP packet's I'm receiving are being split up in to multiple messages. I can't figure out how to reassemble the message. I can concatenate each message, but how do I know that the message is complete? I need to process that data but I need to complete message.
FYI... This is for a scoreboard type application. The statistics are being broadcast via UDP and I'm trying to create an application that will monitor the stats.
Here is some basic code
var dgram = require("dgram");
var server = dgram.createSocket("udp4");
var fs = require('fs');
var STATS;
server.on("message", function (msg, rinfo) {
STATS = STATS + msg;
msg = msg + '<!>';
console.log(msg);
});
// *****************************
// When the message is complete
// Process STATS
// *****************************
server.on("listening", function () {
var address = server.address();
console.log("server listening " +
address.address + ":" + address.port);
});
server.bind(10101);
// server listening 0.0.0.0:41234