installing on Unix/POSIX (and osx):

This module is compatible with ZeroMQ versions 2, 3 and 4. The installation
process varies by platform, but headers are mandatory. Most Linux distributions
provide these headers with -devel packages like zeromq-devel or
zeromq3-devel. Homebrew for OS X provides versions 4 and 3 with packages
zeromq and zeromq3, respectively. A
Chris Lea PPA
is available for Debian-like users who want a version newer than currently
provided by their distribution. Windows is supported but not actively
maintained.

Note: For zap support with versions >=4 you need to have libzmq built and linked
against libsodium. Check the Travis configuration for a list of what is tested
and therefore known to work.

with your platform-specifics taken care of, install and use this module:

Monitoring

You can get socket state changes events by calling to the monitor function.
The supported events are (see ZMQ docs for full description):

connect - ZMQ_EVENT_CONNECTED

connect_delay - ZMQ_EVENT_CONNECT_DELAYED

connect_retry - ZMQ_EVENT_CONNECT_RETRIED

listen - ZMQ_EVENT_LISTENING

bind_error - ZMQ_EVENT_BIND_FAILED

accept - ZMQ_EVENT_ACCEPTED

accept_error - ZMQ_EVENT_ACCEPT_FAILED

close - ZMQ_EVENT_CLOSED

close_error - ZMQ_EVENT_CLOSE_FAILED

disconnect - ZMQ_EVENT_DISCONNECTED

All events get 2 arguments:

fd - The file descriptor of the underlying socket (if available)

endpoint - The underlying socket endpoint

A special monitor_error event will be raised when there was an error in the monitoring process, after this event no more
monitoring events will be sent, you can try and call monitor again to restart the monitoring process.

monitor(interval, numOfEvents)

Will create an inproc PAIR socket where zmq will publish socket state changes events, the events from this socket will
be read every interval (defaults to 10ms).
By default only 1 message will be read every interval, this can be configured by using the numOfEvents parameter,
where passing 0 will read all available messages per interval.

Detaching from the event loop

You may temporarily disable polling on a specific ZMQ socket and let the node.js
process to terminate without closing sockets explicitly by removing their event loop
references. Newly created sockets are already ref()-ed.

unref()

Detach the socket from the main event loop of the node.js runtime.
Calling this on already detached sockets is a no-op.

ref()

Attach the socket to the main event loop.
Calling this on already attached sockets is a no-op.