I'm new with node-js programming, so perhaps I'm not seeing something obvious. A receive in zmq is as follows:
socket.on('message', function()
{
console.log("Message received: ");
console.log(arguments);
});
How do I put in a zmq.Poll, or receive with the zmq.NOBLOCK flag set, or close the socket with linger=0 after the timeout?
Links to any documentation will be appreciated. The zmq guide example on polling, just use the asynchronous callback and not the poller or the timeout. Is it just a setTimeout
and a socket.close()
?
I used something like:
var messageReceived = false;
s.on('message', function() { console.log(arguments); messageReceived=true; });
setTimeout(function() {
if (!messageReceived)
{
console.log("Nothing received. Exiting...");
s.close();
}
}, 5000);
Which works. But I'm not sure if this is the recommended method. Also, how safe is node-zeromq for production?