Created
January 28, 2014 14:39
-
-
Save kessler/8668789 to your computer and use it in GitHub Desktop.
dealer.js
This file contains hidden or 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 zmq = require('zmq') | |
| var socket = zmq.socket('dealer'); | |
| socket.identity = 'client' + process.pid; | |
| var value = 0; | |
| socket.bind('tcp://127.0.0.1: ' + process.argv[2], function(err) { | |
| if (err) throw err; | |
| console.log('bound!'); | |
| setInterval(function() { | |
| value++ | |
| console.log(socket.identity + ': asking ' + value); | |
| socket.send(process.pid + '-' + value); | |
| }, 1000); | |
| socket.on('message', function(data) { | |
| console.log(socket.identity + ': answer data ' + data); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment