ping_discover_network 0.2.0+1 copy "ping_discover_network: ^0.2.0+1" to clipboard
ping_discover_network: ^0.2.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/ping_discover_network.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)'));
}
70
likes
40
pub points
88%
popularity

Publisher

verified publishertablemi.com

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

License

BSD-3-Clause (license)

Dependencies

flutter

More

Packages that depend on ping_discover_network