How to use the zeromq.options function in zeromq

To help you get started, we’ve selected a few zeromq examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github holochain / n3h / packages / n3h-ipc / lib / server.js View on Github external
async init () {
    await super.init()

    super.$pushDestructor(() => {
      this._clients = null
      this._awaitBind = null
      this._socket.close()
      this._socket = null
      clearInterval(this._pruneClientsTimer)
    })

    this._awaitBind = new Map()
    this._clients = new Map()

    this._socket = zmq.socket('router')
    this._socket.setsockopt(zmq.options.identity, msg.SRV_ID)
    this._socket.on('message', (...args) => {
      this._handleMessage(...args)
    })
    this._socket.on('error', (...args) => {
      console.error(args)
      process.exit(1)
    })
    this._socket.on('bind', b => {
      this._handleBind(b, this._socket.last_endpoint)
    })

    this._pruneClientsTimer = setInterval(() => {
      this._pruneClients()
    }, 1500)
  }
github holochain / n3h / lib / ipc / server.js View on Github external
this._startPromise = new Promise((resolve, reject) => {
      const toBind = {}

      const bindTimeout = setTimeout(() => {
        reject(new Error('timeout binding to: ' + Object.keys(toBind)))
      }, 1000)

      this._socket = zmq.socket('router')
      this._socket.setsockopt(zmq.options.identity, common.SRV_ID)
      this._socket.on('message', (...args) => {
        this._handleMessage(...args)
      })
      this._socket.on('error', (...args) => {
        console.error(args)
        process.exit(1)
      })

      this._socket.on('bind', (binding) => {
        delete toBind[binding]
        if (Object.keys(toBind).length < 1) {
          clearTimeout(bindTimeout)
          resolve()
        }
      })
      for (let b of bind) {
github 0rpc / zerorpc-node / lib / socket.js View on Github external
MultiplexingSocket.prototype.close = function(linger) {
	if (this.closed()) {
		throw Error("Socket already closed");
	}
    if (linger !== undefined) {
        this._zmqSocket.setsockopt(zmq.options.linger, linger);
    }

    this._zmqSocket.close();
    for(var id in this.channels) this.channels[id].destroy();
	this._closed = true;
};

zeromq

Next-generation ZeroMQ bindings for Node.js

MIT
Latest version published 12 days ago

Package Health Score

87 / 100
Full package analysis