How to use the dgram.createSocket function in dgram

To help you get started, we’ve selected a few dgram 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 parnic / node-screenlogic / index.js View on Github external
constructor() {
    super();
    this.finder = dgram.createSocket('udp4');
    var _this = this;
    this.finder.on('message', function(message, remote) {
      _this.foundServer(message, remote);
    }).on('close', function() {
      // console.log('finder closed');
    });
  }
github numbat-metrics / numbat-collector / lib / output-graphite.js View on Github external
var GraphiteUDP = module.exports = function GraphiteUDP(opts)
{
	assert(opts && _.isObject(opts), 'you must pass an options object');
	assert(opts.host && _.isString(opts.host), 'you must pass a hostname in the `host` option');
	assert(opts.port && _.isNumber(opts.port), 'you must pass a `port` option');

	stream.Writable.call(this, { objectMode: true });
	if (!opts.batchDelay || !_.isNumber(opts.batchDelay)) opts.batchDelay = 5000; // in ms

	this.socket = dgram.createSocket('udp4');
	this.socket.on('error', this.onError.bind(this));

	this.options = opts;
	this.log = bole('graphite ' + opts.host + ':' + opts.port);
	this.log.info('graphite output configured @ ' + opts.host + ':' + opts.port);
};
util.inherits(GraphiteUDP, stream.Writable);
github juliusv / ne-statsd-backend / ne_statsd_backend.js View on Github external
function StatsdBackend(startupTime, config, events) {
  var self = this;
  this.config = config.statsdBackend;
  this.max_payload_length = (this.config.mtu || 1500) - 8; // 8 = UDP header length.
  this.socket = dgram.createSocket('udp4');
  this.metric_lines = {};
  events.on('flush', function(time_stamp, metrics) { self.flush(time_stamp, metrics); });
}
github CoderDojo / cp-dojos-service / test / lib / service.js View on Github external
seneca.ready(function() {
  var message = new Buffer(service);
  var client = dgram.createSocket('udp4');
  client.send(message, 0, message.length, 11404, 'localhost', function (err, bytes) {
    client.close();
  });

  seneca.add({role: service, cmd: 'suicide'}, function (err, cb) {
    seneca.close(function (err) {
      process.exit(err ? 1: 0);
    });
    cb();
  });
});
github digsjs / digs / test / unit / connections / coap.spec.js View on Github external
it('should also close the TCP server', function(done) {
        sandbox.spy(nodeCoap, 'createServer');
        let tcpServer = createProxy(digs);
        let coapServer = getCoAPServer();
        sandbox.restore(nodeCoap, 'createServer');
        expect(coapServer).to.be.instanceof(nodeCoap.createServer);
        let stub = sandbox.stub();
        tcpServer.on('close', stub);
        coapServer._sock = require('dgram').createSocket('udp4');
        coapServer.close();
        process.nextTick(function() {
          expect(stub).to.have.been.calledOnce;
          done();
        });
      });
    });
github mcollina / node-coap / test / request.js View on Github external
it('should imply a default port', function (done) {
    server2 = dgram.createSocket('udp4')

    server2.bind(5683, function () {
      request('coap://localhost').end()
    })

    server2.on('message', function (msg, rsinfo) {
      ackBack(msg, rsinfo)
      done()
    })
  })
github iproduct / course-node-express-react / 05-nodejs-demo / example12.js View on Github external
var dgram = require('dgram');
var message = new Buffer("Hello from UDP Client!");
var client = dgram.createSocket("udp4");
console.log("Client sending: " + message);
client.send(message, 0, message.length,
    12345, "localhost", function (err, bytes) {
        client.close();
    });
github fh1ch / node-bacstack / lib / transport.js View on Github external
constructor(settings) {
    super();
    this._settings = settings;
    this._server = createSocket({type: 'udp4', reuseAddr: true});
    this._server.on('message', (msg, rinfo) => this.emit('message', msg, rinfo.address));
    this._server.on('error', (err) => this.emit('message', err));
  }
github noia-network / webrtc-direct / server / src / udp-proxy.ts View on Github external
return new Promise(resolve => {
            try {
                this.server = dgram.createSocket("udp4");
                this.registerListeners();
                this.server.bind(this.port, SERVER_ADDRESS, () => {
                    resolve();
                });
            } catch (err) {
                console.error("error", err);
            }
        });
    }
github cn007b / my / ed / nodeJs / _ruBookPauersS / updServer.node.js View on Github external
var dgram = require('dgram');
var server = dgram.createSocket("udp4");
server.on ("message", function(msg, rinfo) {
    console.log("Message: " + msg + " от " + rinfo.address + ":"+ rinfo.port);
});
server.bind(8124);

dgram

This package name is not currently in use, but was formerly occupied by another package. To avoid malicious use, npm is hanging on to the package name, but loosely, and we'll probably give it to you if you want it.

ISC
Latest version published 8 years ago

Package Health Score

50 / 100
Full package analysis

Popular dgram functions