JavaScript Multiple Clients connected to the same Server using UDP in NodeJS

Is it possible to have multiple clients to the same UDP server ? I'd like to broadcast the same data to all connected clients.

Here would be a starting sample, if it helps somehow ...

// Server
var news = [
  "Borussia Dortmund wins German championship",
  "Tornado warning for the Bay Area",
  "More rain for the weekend"
];

var dgram = require('dgram');
var server = dgram.createSocket("udp4");
server.bind(function() {
  server.setBroadcast(true)
  server.setMulticastTTL(128);
  setInterval(broadcastNew, 3000);
});

function broadcastNew() {
  var message = new Buffer(news[Math.floor(Math.random() * news.length)]);
  server.send(message, 0, message.length, 5007, "224.1.1.1");
  console.log("Sent " + message + " to the wire...");
}

// Client 1
var PORT = 5007;
var dgram = require('dgram');
var client = dgram.createSocket('udp4');

client.on('listening', function() {
  var address = client.address();
  console.log('UDP Client listening on ' + address.address + ":" + address.port);
  client.setBroadcast(true)
  client.setMulticastTTL(128);
  client.addMembership('224.1.1.1');
});

client.on('message', function(message, remote) {
  console.log('A: Epic Command Received. Preparing Relay.');
  console.log('B: From: ' + remote.address + ':' + remote.port + ' - ' + message);
});

client.bind(PORT);

// Client 2

// Here would go another client, it is possible ? 
Answer:1

My Node script has this in it: var connection = mysql.createConnection(...); connection.connect(); connection.query(/*sql query*/, function(err, rows, fields){ app.get('/', function(req, res){ ...

My Node script has this in it: var connection = mysql.createConnection(...); connection.connect(); connection.query(/*sql query*/, function(err, rows, fields){ app.get('/', function(req, res){ ...

  1. node js jade
  2. node js jade tutorial
  3. node js jade example
  4. node js jade template
  5. node.js jade vs ejs
  6. node js jade table example
  7. node.js jade template tutorial
  8. node js jade vs pug
  9. node js jade bootstrap
  10. node.js jade alternatives
  11. node js jade table
  12. node js jade button onclick
  13. node js jade vs handlebars
  14. node js jade form
  15. node js jade template engine
  16. node js jade to html
  17. node js jade mysql
  18. node js jade css
  19. node.js jade template variables
  20. node js jade tutorial pdf

I'm trying to dynamically add new key/value pairs to an existing json map using jquery/javascript. An example of my structure is as follows: var widgetTypes = { "CLASS_A": { "A1": "A1 ...

I'm trying to dynamically add new key/value pairs to an existing json map using jquery/javascript. An example of my structure is as follows: var widgetTypes = { "CLASS_A": { "A1": "A1 ...

  1. adding key values to dictionary python
  2. adding key values to dictionary c#
  3. adding key values in web.config

I've a written a JavaScript that opens a specific page in the "content" div when I click on a link. HTML: <li><a href='#' onclick="load_shift_test()">Soft Drinks</a></li> JS:...

I've a written a JavaScript that opens a specific page in the "content" div when I click on a link. HTML: <li><a href='#' onclick="load_shift_test()">Soft Drinks</a></li> JS:...

I'm using Select2 Plugin in my asp.net mvc 5 application. according to the documentation The placeholder option allows you to pass in a data object instead of just a string if you need more ...

I'm using Select2 Plugin in my asp.net mvc 5 application. according to the documentation The placeholder option allows you to pass in a data object instead of just a string if you need more ...

  1. select2 placeholder not displaying
  2. select2 placeholder not showing