MDNS

MDNS

Listen for MDNS queries and responses as well as make your own MDNS requests.

Example

Example direct query. Example Results: 1, 2

import Agent from '@meldcx/agent';
const agent = new Agent();

const init = async() => {
    await agent.onReadyAsync();

    const name = '_NMS-SAP._tcp.local';

    console.log(`Querying for: ${name}`);
    const response = await agent.MDNS.query(name, agent.MDNS.RecordTypes.PTR);
    console.log('Got response', response);
};

init();

Members

RecordTypes

List of DNS Record types

See:

Methods

onQuery(callback)

Register a callback for when a query DNS Message is received.

Parameters:
Name Type Description
callback function

The function to call when this event is fired.

onResponse(callback)

Register a callback for when a response DNS Message is received.

Parameters:
Name Type Description
callback function

The function to call when this event is fired.

(async) query(name, type) → {Promise.<module:MDNS~DNSMessage>}

Query for a specific DNS record

Parameters:
Name Type Description
name string

The DNS Name to query

type Integer

The Record type to query