osociety / network_tools

Networking Tools library which can help you discover open ports, devices on subnet and many other things.
https://pub.dev/packages/network_tools
BSD 3-Clause "New" or "Revised" License
45 stars 13 forks source link

Consider `HostScanner.discover` to return a `Future<List<ActiveHost>>` instead of `Stream<ActiveHost>` #43

Closed ivirtex closed 2 years ago

ivirtex commented 2 years ago

Since all ping actions are started asynchronously, they will complete aprroximately at the same time. This means that almost all the results are yielded also at the same time, this behaviour doesn't really fit the purpose of Dart's streams. Converting HostScanner.discover to return a Future would simplify the code and logic.

guyluz11 commented 2 years ago

This could have been a good change if discover (now name getting changed to getAllPingableDevices) didn't support changing the timeout.

So if the developer changes the timeout to 1 minute then the results can also not get returned at approximately the same time in Stream.

git-elliot commented 2 years ago

If the address is Class A, user have to wait for all the futures to be completed in order to get the result from getAllPingableDevices(formerly discover) method. https://github.com/git-elliot/network_tools/blob/ffcd5ed42a457c0646c5589132f4a6a98ef66667/network_tools/lib/src/host_scanner.dart#L25

https://github.com/git-elliot/network_tools/blob/ffcd5ed42a457c0646c5589132f4a6a98ef66667/network_tools/lib/src/host_scanner.dart#L146

ivirtex commented 2 years ago

Right, I forgot about the timeout property.