How to use the mdns.loopbackInterface function in mdns

To help you get started, we’ve selected a few mdns 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 AndreasMadsen / tcpnet / tcpnet.js View on Github external
if (isAny || networkName === LOOPBACK_NAME) {
    this._loopbackAllowed = true;
  }

  // Special case, where loopback interface is used
  if (networkName === LOOPBACK_NAME) {

    // There is a linux-avahi exception when dealling with a loopback interface
    if (mdns.isAvahi) {
      return callback(
        new Error('loopback address is not supported on linux-avahi platform')
      );
    }

    // Use specical key
    network = mdns.loopbackInterface();
  } else if (isAny) {
    network = undefined;
  }

  this._discover = mdns.createBrowser(this._key, {
    networkInterface: network
  });

  this._discover.on('error', this._relayError);

  this._discover.start();

  this._announce = mdns.createAdvertisement(
    this._key, this._address.port, {
      // workaround for some wird bug
      // ref: https://github.com/agnat/node_mdns/issues/51
github DefinitelyTyped / DefinitelyTyped / mdns / mdns-tests.ts View on Github external
}

function MCHammer(options:any) {
    options = options || {};
    return function MCHammer(service:HammerTimeService, next:()=>void) {
        console.log('STOP!');
        setTimeout(function() {
            console.log('hammertime...');
            service.hammerTime = new Date();
            next();
        }, options.delay || 1000);
    }
}

var browser = mdns.createBrowser( mdns.tcp('http')
    , { networkInterface: mdns.loopbackInterface()});

var ad:MDNS.Advertisement;

function createAdvertisement() {
    try {
        ad = mdns.createAdvertisement(mdns.tcp('http'), 1337);
        ad.on('error', handleError);
        ad.start();
    } catch (ex) {
        handleError(ex);
    }
}

function handleError(error:MDNS.DnsSdError) {
    switch (error.errorCode) {
        case mdns.kDNSServiceErr_Unknown: