network_discovery

Last updated:

0 purchases

network_discovery Image
network_discovery Images
Add to Cart

Description:

network discovery

network_discovery #
Dart/Flutter library that allows to ping IP subnet and discover network devices.
Could be used to find available host or services like http server (e.g. on port 80) and any other services on local network.
The device should be connected to a Router (a.s WIFI or Wired connection).
The library tested on Android, iOS, Windows and Linux platforms should work on your mac but has not been tested.
Getting Started #
Check complete example in /example folder.
Discover network device ip address:
import 'package:network_discovery/network_discovery.dart';

// Must be async function
final String deviceIP = await NetworkDiscovery.discoverDeviceIpAddress();

if(deviceIP.isNotEmpty){
print(deviceIP);
// Can use to get subnet from IP Address
final String subnet = address.substring(0, address.lastIndexOf('.'));
}else{
print("Couldn't get IP Address");
}
copied to clipboard
Discover an available port at a given address and port:
import 'package:network_discovery/network_discovery.dart';

// Must be async function
const port = 80;
final device = await NetworkDiscovery.discoverFromAddress('192.168.0.1', port);

print(device.toString());
copied to clipboard
Discover available ports at a given address and various ports:
import 'package:network_discovery/network_discovery.dart';

// Must be async function
const List<int> ports = [80, 443, 445, 8080];
final device = await NetworkDiscovery.discoverFromAddressMultiplePorts('192.168.0.1', ports);

print(device.toString());
copied to clipboard
Discover available host on network in a given subnet:
import 'package:network_discovery/network_discovery.dart';

final stream = NetworkDiscovery.discoverAllPingableDevices('192.168.0');

int availableHost = 0;
stream.listen((HostActive host) {
print('Found device: ${host.ip}, isActive: ${host.isActive}');
if(host.isActive){
found++;
}
}).onDone(() => print('Finish. Available $availableHost host device(s)'));
copied to clipboard
Discover available network devices in a given subnet and port:
import 'package:network_discovery/network_discovery.dart';

const port = 80;
final stream = NetworkDiscovery.discover('192.168.0', port);

int found = 0;
stream.listen((NetworkAddress addr) {
found++;
print('Found device: ${addr.ip}:$port');
}).onDone(() => print('Finish. Found $found device(s)'));
copied to clipboard
Discover available network devices on a given subnet and various ports:
import 'package:network_discovery/network_discovery.dart';

const List<int> ports = [80, 443, 445, 8080];
final stream = NetworkDiscovery.discoverMultiplePorts('192.168.0', ports);

int found = 0;
stream.listen((NetworkAddress addr) {
found++;
print('Found device: ${addr.ip}:$port');
}).onDone(() => print('Finish. Found $found device(s)'));
copied to clipboard

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.