Permalink
Browse files

misc

  • Loading branch information...
1 parent 9116dd5 commit 7689a49c931d40f17e069f96d6a395e416317423 @tj tj committed Mar 14, 2012
Showing with 34 additions and 0 deletions.
  1. +17 −0 examples/http/broker.js
  2. +17 −0 examples/rpc.js
View
17 examples/http/broker.js
@@ -0,0 +1,17 @@
+
+var zmq = require('../../')
+ , router = zmq.socket('router')
+ , dealer = zmq.socket('dealer');
+
+router.on('message', function(){
+ dealer.send(Array.apply(arguments));
+});
+
+dealer.on('message', function(){
+ router.send(Array.apply(arguments));
+});
+
+router.bind('tcp://127.0.0.1:5000');
+dealer.bind('tcp://127.0.0.1:5001');
+console.log('router bound to :5000');
+console.log('dealer bound to :5001');
View
17 examples/rpc.js
@@ -0,0 +1,17 @@
+
+/**
+ * One server two clients
+ */
+
+var cluster = require('cluster')
+ , zmq = require('../')
+ , port = 'tcp://127.0.0.1:12345';
+
+if (cluster.isMaster) {
+ for (var i = 0; i < 2; i++) cluster.fork();
+
+
+} else {
+ var sock = zmq.socket('dealer');
+ sock.connect(port);
+}

0 comments on commit 7689a49

Please sign in to comment.