Simple broadcasting and repeating of JSON messages using net sockets
Latest commit 2ce32bc Mar 15, 2014 @ajlopez Version 0.0.4
Failed to load latest commit information.
lib for Broadcast sample, add client.on('error' in code, consum… Apr 28, 2013
.gitignore Initial commit Jun 9, 2012
.npmignore Initial commit Jun 9, 2012


Simple broadcasting of JSON messages using net sockets.


Via npm on Node:

npm install simplebroadcast

Reference it from your program:

var simplebroadcast = require('simplebroadcast');


Broadcaster (server) side

var broadcaster = simplebroadcast.createBroadcaster();


Client side

var client = simplebroadcast.createClient();

client.on('message', function(message) {
    // message processing

client.connect(port, host);

// broadcasting a message, after connection
client.on('connect', function() {

A broadcaster can connect to another broadcaster. Each one is the cliente of the other.

broadcaster.connect(port, host));

You can build a tree of broacasters. A tree is a graph without cycles. If the graph of broadcasters has a cycle, you messages will be send forever.

A broadcaster can act as a repeater, listening to other repeateres, or connecting as a repeater to another one.

broadcaster.connectRepeater(8002, 'repeater2');

The messages sent by a repeater are sent to all clients, but not to other repeaters. The messages sent by a client are sent to the others clients and to all repeaters. In this way, you can build a graph of repeaters, including cycles. Usually it is an star graph were each repeater is connected to all the others.


git clone git://
cd SimpleBroadcast
npm install
npm test


Broadcast messages to many clients sample shows how you send and receive messages to/from many clients thru a broadcast server.


  • 0.0.1: Published
  • 0.0.2: Published
  • 0.0.3: Published, updated to use SimpleMessages 0.4. Adding error event to client in code.
  • 0.0.4: Published, updated to use SimpleMessages 0.6


Feel free to file issues and submit pull requests — contributions are welcome.

If you submit a pull request, please be sure to add or update corresponding test cases, and ensure that npm test continues to pass.

(Thanks to JSON5 by aseemk. This file is based on that project