multicast_dns 0.1.0+1

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • new39

Multicast DNS package #

pub package

A Dart package to do service discovery over multicast DNS (mDNS), Bonjour, and Avahi.

Usage #

To use this package, add multicast_dns as a dependency in your pubspec.yaml file.

Example #

Import the library via

import 'package:multicast_dns/mdns_client.dart';

Then use the MDnsClient Dart class in your code. To see how this is done, check out the example app or the sample implementations in the bin directory.

0.1.0 #

  • Initial Open Source release.
  • Migrates the dartino-sdk's mDNS client to Dart 2.0 and Flutter's analysis rules
  • Breaks from original Dartino code, as it does not use native libraries for macOS and overhauls the ResourceRecord class.

example/main.dart

// Copyright 2018, the Flutter project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// Example script to illustrate how to use the mdns package to discover the port
// of a Dart observatory over mDNS.

import 'package:multicast_dns/multicast_dns.dart';

void main() async {
  // Parse the command line arguments.

  const String name = '_dartobservatory._tcp.local';
  final MDnsClient client = MDnsClient();
  // Start the client with default options.
  await client.start();

  // Get the PTR recod for the service.
  await for (PtrResourceRecord ptr in client
      .lookup<PtrResourceRecord>(ResourceRecordQuery.serverPointer(name))) {
    // Use the domainName from the PTR record to get the SRV record,
    // which will have the port and local hostname.
    // Note that duplicate messages may come through, especially if any
    // other mDNS queries are running elsewhere on the machine.
    await for (SrvResourceRecord srv in client.lookup<SrvResourceRecord>(
        ResourceRecordQuery.service(ptr.domainName))) {
      // Domain name will be something like "io.flutter.example@some-iphone.local._dartobservatory._tcp.local"
      final String bundleId =
          ptr.domainName; //.substring(0, ptr.domainName.indexOf('@'));
      print('Dart observatory instance found at '
          '${srv.target}:${srv.port} for "$bundleId".');
    }
  }
  client.stop();

  print('Done.');
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  multicast_dns: ^0.1.0+1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:multicast_dns/multicast_dns.dart';
  
Version Uploaded Documentation Archive
0.1.0+1 Jan 24, 2019 Go to the documentation of multicast_dns 0.1.0+1 Download multicast_dns 0.1.0+1 archive
0.1.0 Jan 24, 2019 Go to the documentation of multicast_dns 0.1.0 Download multicast_dns 0.1.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
53
Health:
Code health derived from static analysis. [more]
0
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
62
Overall:
Weighted score of the above. [more]
39
Learn more about scoring.

We analyzed this package on Feb 14, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.1.0
  • pana: 0.12.13

Platforms

Detected platforms:

Error(s) prevent platform classification:

Fix dependencies in pubspec.yaml.

Analysis issues and suggestions

Fix dependencies in pubspec.yaml.

Running pub upgrade failed with the following output:

ERR: The current Dart SDK version is 2.1.0.
 
 Because multicast_dns requires SDK version >=2.1.1-dev.2.0 <3.0.0, version solving failed.

Maintenance issues and suggestions

Fix platform conflicts. (-20 points)

Error(s) prevent platform classification:

Fix dependencies in pubspec.yaml.

Make sure dartdoc successfully runs on your package's source files. (-10 points)

Dependencies were not resolved.

The package description is too short. (-8 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.1-dev.2.0 <3.0.0