Created
April 7, 2011 10:31
-
-
Save timcash/907514 to your computer and use it in GitHub Desktop.
a test for publish speed of zeromq in nodejs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var cnt, mes, s, sender, util, zmq; | |
zmq = require('zeromq'); | |
util = require('util'); | |
s = zmq.createSocket('pub'); | |
s.bind('tcp://127.0.0.1:5559', function(err) { | |
if (err) { | |
throw err; | |
} | |
util.puts('binding'); | |
}); | |
cnt = 1; | |
mes = function() { | |
var data; | |
data = "" + cnt; | |
if (cnt % 100 === 0) { | |
util.puts("sending " + data); | |
} | |
s.send(data); | |
cnt++; | |
}; | |
sender = setInterval(mes, 1); | |
process.on('SIGINT', function() { | |
clearInterval(sender); | |
s.close(); | |
console.log("Quitting now"); | |
process.exit(1); | |
}); | |
util.puts('Ready to go!'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment