Skip to content

Instantly share code, notes, and snippets.

@bcg
Created April 6, 2011 22:45
Show Gist options
  • Select an option

  • Save bcg/906701 to your computer and use it in GitHub Desktop.

Select an option

Save bcg/906701 to your computer and use it in GitHub Desktop.

Revisions

  1. bcg created this gist Apr 6, 2011.
    8 changes: 8 additions & 0 deletions client.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    var zmq = require('zeromq');

    s = zmq.createSocket('push');
    s.connect('tcp://127.0.0.1:15000');

    while (true) { // ZOMG he did it again!
    s.send(new Buffer("test"));
    }
    26 changes: 26 additions & 0 deletions node-zmqd.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    var zmq = require('zeromq'),
    util = require('util'),
    redis = require("redis"),
    client = redis.createClient();

    s = zmq.createSocket('pull');

    var count = 0;
    var time = null;

    s.bind('tcp://127.0.0.1:15000', function(err) {
    if (err) throw err;
    s.on('message', function(data) {
    client.lpush('q', data.toString());
    count++;
    if (count == 1) {
    time = new Date();
    }
    if ((count % 10000) === 0) {
    var t = new Date();
    console.log('T: ' + ((t-time)/1000));
    time = t;
    }
    });
    util.puts('Server is up ...');
    });