Browse files

Use TCP_KEEPALIVE_* constants instead of raw number.

And with improves on unit tests to consist of.
  • Loading branch information...
1 parent eeaabef commit 6993565954ffc5e0c9cfadb0163b9db96c0e27c8 @soplwang soplwang committed Feb 4, 2013
Showing with 18 additions and 12 deletions.
  1. +12 −8 binding.cc
  2. +2 −1 test/test.socket.hwm.3-x.js
  3. +4 −3 test/test.socket.messages.lateconnect.js
View
20 binding.cc
@@ -442,10 +442,12 @@ namespace zmq {
case ZMQ_LINGER:
case ZMQ_RECONNECT_IVL:
case ZMQ_BACKLOG:
- case 34:
- case 35:
- case 36:
- case 37:
+#if ZMQ_VERSION_MAJOR > 2
+ case ZMQ_TCP_KEEPALIVE:
+ case ZMQ_TCP_KEEPALIVE_CNT:
+ case ZMQ_TCP_KEEPALIVE_IDLE:
+ case ZMQ_TCP_KEEPALIVE_INTVL:
+#endif
return socket->GetSockOpt<int>(option);
case ZMQ_SUBSCRIBE:
case ZMQ_UNSUBSCRIBE:
@@ -488,10 +490,12 @@ namespace zmq {
case ZMQ_LINGER:
case ZMQ_RECONNECT_IVL:
case ZMQ_BACKLOG:
- case 34:
- case 35:
- case 36:
- case 37:
+#if ZMQ_VERSION_MAJOR > 2
+ case ZMQ_TCP_KEEPALIVE:
+ case ZMQ_TCP_KEEPALIVE_CNT:
+ case ZMQ_TCP_KEEPALIVE_IDLE:
+ case ZMQ_TCP_KEEPALIVE_INTVL:
+#endif
return socket->SetSockOpt<int>(option, args[1]);
case ZMQ_RCVMORE:
case ZMQ_EVENTS:
View
3 test/test.socket.hwm.3-x.js
@@ -1,9 +1,10 @@
var zmq = require('../')
, should = require('should')
+ , semver = require('semver')
, sock = zmq.socket('req');
-if (zmq.version >= '3.0.0') {
+if (semver.satisfies(zmq.version, '3.x')) {
// ZMQ_SNDHWM
sock.getsockopt(zmq.ZMQ_SNDHWM).should.not.equal(1);
sock.setsockopt(zmq.ZMQ_SNDHWM, 1).should.equal(sock);
View
7 test/test.socket.messages.lateconnect.js
@@ -1,6 +1,7 @@
var zmq = require('../')
- , should = require('should');
+ , should = require('should')
+ , semver = require('semver');
var push = zmq.socket('push')
, pull = zmq.socket('pull');
@@ -28,10 +29,10 @@ setTimeout(function () {
n.should.equal(3);
}, 1*1000);
-if (zmq.version >= '3.0.0') {
+if (semver.satisfies(zmq.version, '3.x')) {
push.setsockopt(zmq.ZMQ_SNDHWM, 1);
pull.setsockopt(zmq.ZMQ_RCVHWM, 1);
-} else {
+} else if (semver.satisfies(zmq.version, '2.x')) {
push.setsockopt(zmq.ZMQ_HWM, 1);
pull.setsockopt(zmq.ZMQ_HWM, 1);
}

0 comments on commit 6993565

Please sign in to comment.