ping_discover_network_forked 0.0.1 copy "ping_discover_network_forked: ^0.0.1" to clipboard
ping_discover_network_forked: ^0.0.1 copied to clipboard

Library that allows to ping IP subnet and discover network devices. Could be used to find printers and other devices and services in a local network.

example/main.dart

/*
 * ping_discover_network
 * Created by Andrey Ushakov
 * 
 * See LICENSE for distribution and usage details.
 */

import 'package:ping_discover_network_forked/ping_discover_network_forked.dart';

/// Discover available network devices in a given subnet on a given port
void main() async {
  // NetworkAnalyzer.discover pings PORT:IP one by one according to timeout.
  // NetworkAnalyzer.discover2 pings all PORT:IP addresses at once.

  const port = 80;
  final stream = NetworkAnalyzer.discover2(
    '192.168.0',
    port,
    timeout: Duration(milliseconds: 5000),
  );

  int found = 0;
  stream.listen((NetworkAddress addr) {
    // print('${addr.ip}:$port');
    if (addr.exists) {
      found++;
      print('Found device: ${addr.ip}:$port');
    }
  }).onDone(() => print('Finish. Found $found device(s)'));
}
22
likes
150
pub points
92%
popularity

Publisher

unverified uploader

Library that allows to ping IP subnet and discover network devices. Could be used to find printers and other devices and services in a local network.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

flutter

More

Packages that depend on ping_discover_network_forked