Simple broadcasting and repeating of JSON messages using net sockets
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


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