Announce and look up services on a local network using mdns.
npm install multicast-service-discoveryAnnounce and look up services on a local network using mdns.
``shell`
npm i multicast-service-discovery
See the generated API docs.
See the examples directory for a very basic example as well as usage with net.createServer and hypercore.
`js
import { MdnsDiscovery } from 'multicast-service-discovery'
const discover = new MdnsDiscovery()
discover.announce('mdns-basic-example', { port: 3456 })
`
`js
import { MdnsDiscovery } from 'multicast-service-discovery'
const discover = new MdnsDiscovery()
discover.on('service', (service) => {
console.log('found service:', service)
})
discover.lookup('mdns-basic-example')
`
If you see Error: Timed out getting default route` when using with nodejs versions >=18.0.0 to <18.4.0, upgrade to at least 18.4.0 to resolve this.