diff --git a/lib/index.js b/lib/index.js index 1ef5508..2b2a688 100644 --- a/lib/index.js +++ b/lib/index.js @@ -99,7 +99,8 @@ function gcWrap (self) {} function Socket(type) { this.type = type; - this._zmq = new zmq.Socket(defaultContext(), types[type]); + this._type = typeof type === 'number' ? type : types[type]; + this._zmq = new zmq.Socket(defaultContext(), this._type); this._zmq.onReady = this._flush.bind(this); this._outgoing = []; this._shouldFlush = true; diff --git a/test/test.socket.js b/test/test.socket.js index 60b110e..bae1b7d 100644 --- a/test/test.socket.js +++ b/test/test.socket.js @@ -11,6 +11,11 @@ zmq.createSocket.should.equal(zmq.socket); var sock = zmq.socket('req'); sock.type.should.equal('req'); sock.close.should.be.a('function'); +sock.close(); + +sock = zmq.socket(zmq.ZMQ_REQ); +sock.type.should.equal(zmq.ZMQ_REQ); +sock.close.should.be.a('function'); // setsockopt