Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
370 additions
and
17 deletions.
There are no files selected for viewing
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
|
||
var zmq = require('../../') | ||
, sock = zmq.socket('push'); | ||
|
||
sock.bindSync('tcp://127.0.0.1:3000'); | ||
console.log('Producer bound to port 3000'); | ||
|
||
setInterval(function(){ | ||
console.log('sending work'); | ||
sock.send('some work'); | ||
}, 500); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
var zmq = require('../../') | ||
, sock = zmq.socket('pull'); | ||
|
||
sock.connect('tcp://127.0.0.1:3000'); | ||
console.log('Worker connected to port 3000'); | ||
|
||
sock.on('message', function(msg){ | ||
console.log('work: %s', msg.toString()); | ||
}); |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"author": "Matthias Goetzke <m.goetzke@curasystems.de> (https://twitter.com/mgoetzke)", | ||
"name": "zmq-windows", | ||
"description": "test of zeromq bindings for windows", | ||
"version": "0.0.1", | ||
"homepage": "https://github.com/matthiasg", | ||
"main": "./index.js", | ||
"bin": "./bin/ariel.js", | ||
"engines": { | ||
"node": ">= 0.6" | ||
}, | ||
"dependencies": { | ||
"bindings": "> 0.3.0" | ||
}, | ||
"devDependencies": { | ||
"should": ">= 0.5.1", | ||
"ariel": "*" | ||
}, | ||
"optionalDependencies": {} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
for %f in (test\*.js) do call node %f |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/usr/bin/env bash | ||
|
||
echo | ||
files=test/test.*.js | ||
for file in $files; do | ||
printf "\033[90m ${file#test/}\033[0m " | ||
node $@ $file && printf "\033[36m✓\033[0m\n" | ||
test $? -eq 0 || exit $? | ||
done | ||
echo |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
var zmq = require('../') | ||
, should = require('should'); | ||
|
||
var rep = zmq.socket('rep') | ||
, req = zmq.socket('req'); | ||
|
||
rep.on('message', function(msg){ | ||
msg.should.be.an.instanceof(Buffer); | ||
msg.toString().should.equal('hello'); | ||
rep.send('world'); | ||
}); | ||
|
||
rep.bind('inproc://stuff'); | ||
|
||
rep.on('bind', function(){ | ||
req.connect('inproc://stuff'); | ||
req.send('hello'); | ||
req.on('message', function(msg){ | ||
msg.should.be.an.instanceof(Buffer); | ||
msg.toString().should.equal('world'); | ||
req.close(); | ||
rep.close(); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
|
||
var zmq = require('../') | ||
, should = require('should'); | ||
|
||
// .socket | ||
|
||
var sock = zmq.socket('req'); | ||
sock.type.should.equal('req'); | ||
sock.close.should.be.a('function'); | ||
|
||
// options | ||
|
||
zmq.socket('req', { backlog: 30 }).backlog.should.equal(30); | ||
|
||
// setsockopt | ||
|
||
sock.getsockopt(zmq.ZMQ_BACKLOG).should.not.equal(75); | ||
sock.setsockopt(zmq.ZMQ_BACKLOG, 75).should.equal(sock); | ||
sock.getsockopt(zmq.ZMQ_BACKLOG).should.equal(75); | ||
sock.setsockopt(zmq.ZMQ_BACKLOG, 100); | ||
|
||
// setsockopt + string sugar | ||
|
||
sock.getsockopt('backlog').should.not.equal(75); | ||
sock.setsockopt('backlog', 75).should.equal(sock); | ||
sock.getsockopt('backlog').should.equal(75); | ||
|
||
// setsockopt sugar | ||
|
||
sock.backlog.should.be.a('number'); | ||
sock.backlog.should.not.equal(50); | ||
sock.backlog = 50; | ||
sock.backlog.should.equal(50); | ||
|
||
process.exit(0); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
|
||
var zmq = require('../') | ||
, should = require('should'); | ||
|
||
var push = zmq.socket('push') | ||
, pull = zmq.socket('pull'); | ||
|
||
var n = 0; | ||
|
||
pull.on('message', function(msg){ | ||
msg = msg.toString(); | ||
switch (n++) { | ||
case 0: | ||
msg.should.equal('string'); | ||
break; | ||
case 1: | ||
msg.should.equal('15.99'); | ||
break; | ||
case 2: | ||
msg.should.equal('buffer'); | ||
push.close(); | ||
pull.close(); | ||
break; | ||
} | ||
}); | ||
|
||
pull.bind('inproc://stuff', function(){ | ||
push.connect('inproc://stuff'); | ||
push.send('string'); | ||
push.send(15.99); | ||
push.send(new Buffer('buffer')); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|
||
var zmq = require('../') | ||
, should = require('should'); | ||
|
||
var push = zmq.socket('push') | ||
, pull = zmq.socket('pull'); | ||
|
||
pull.on('message', function(msg1, msg2, msg3){ | ||
msg1.toString().should.equal('string'); | ||
msg2.toString().should.equal('15.99'); | ||
msg3.toString().should.equal('buffer'); | ||
push.close(); | ||
pull.close(); | ||
}); | ||
|
||
pull.bind('inproc://stuff', function(){ | ||
push.connect('inproc://stuff'); | ||
push.send(['string', 15.99, new Buffer('buffer')]); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
|
||
var zmq = require('../') | ||
, should = require('should'); | ||
|
||
var push = zmq.socket('push') | ||
, pull = zmq.socket('pull'); | ||
|
||
pull.on('message', function(a, b, c, d, e){ | ||
a.toString().should.equal('tobi'); | ||
b.toString().should.equal('loki'); | ||
c.toString().should.equal('jane'); | ||
d.toString().should.equal('luna'); | ||
e.toString().should.equal('manny'); | ||
push.close(); | ||
pull.close(); | ||
}); | ||
|
||
pull.bind('inproc://stuff', function(){ | ||
push.connect('inproc://stuff'); | ||
push.send(['tobi', 'loki'], zmq.ZMQ_SNDMORE); | ||
push.send(['jane', 'luna'], zmq.ZMQ_SNDMORE); | ||
push.send('manny'); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
|
||
var zmq = require('../') | ||
, should = require('should'); | ||
|
||
var pub = zmq.socket('pub') | ||
, sub = zmq.socket('sub'); | ||
|
||
var n = 0; | ||
|
||
sub.subscribe('js'); | ||
sub.subscribe('luna'); | ||
|
||
sub.on('message', function(msg){ | ||
msg.should.be.an.instanceof(Buffer); | ||
switch (n++) { | ||
case 0: | ||
msg.toString().should.equal('js is cool'); | ||
break; | ||
case 1: | ||
msg.toString().should.equal('luna is cool too'); | ||
pub.close(); | ||
sub.close(); | ||
break; | ||
} | ||
}); | ||
|
||
sub.bind('inproc://stuff', function(){ | ||
pub.connect('inproc://stuff'); | ||
pub.send('js is cool'); | ||
pub.send('ruby is meh'); | ||
pub.send('py is pretty cool'); | ||
pub.send('luna is cool too'); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
|
||
var zmq = require('../') | ||
, should = require('should'); | ||
|
||
var pub = zmq.socket('pub') | ||
, sub = zmq.socket('sub'); | ||
|
||
var n = 0; | ||
|
||
sub.subscribe(''); | ||
sub.on('message', function(msg){ | ||
msg.should.be.an.instanceof(Buffer); | ||
switch (n++) { | ||
case 0: | ||
msg.toString().should.equal('foo'); | ||
break; | ||
case 1: | ||
msg.toString().should.equal('bar'); | ||
break; | ||
case 2: | ||
msg.toString().should.equal('baz'); | ||
sub.close(); | ||
pub.close(); | ||
break; | ||
} | ||
}); | ||
|
||
sub.bind('inproc://stuff', function(){ | ||
pub.connect('inproc://stuff'); | ||
pub.send('foo'); | ||
pub.send('bar'); | ||
pub.send('baz'); | ||
}); |
Oops, something went wrong.