Repository: flutter
Issue: [Linux]: multicast_dns: Failed to create datagram socket (OS Error: Too many open files, errno = 24)
Labels: platform-linux,package,p: multicast_dns,team-ecosystem,P2,triaged-ecosystem

<!-- Thank you for using Flutter!

     If you are looking for support, please check out our documentation
     or consider asking a question on Stack Overflow:
      * https://flutter.dev/
      * https://api.flutter.dev/
      * https://stackoverflow.com/questions/tagged/flutter?sort=frequent

     If you have found a bug or if our documentation doesn't have an answer
     to what you're looking for, then fill out the template below. Please read
     our guide to filing a bug first: https://flutter.dev/docs/resources/bug-reports
-->

## Steps to Reproduce

<!-- Please include full steps to reproduce so we can reproduce the problem. -->

1. Find arm device using Linux (Preferred with less than 1GB ram)
2. git clone https://github.com/guyluz11/multicast_dns_error_repo/tree/main/bin.
3. Run the project (preferably with dart version `Dart SDK version: 2.18.2 (stable) (Tue Sep 27 13:24:11 2022 +0200) on "linux_arm"`).
5. Wait about Half an hour (for me it didn't exceed 11m).

**Expected results:** <!-- what did you want to see? -->
mDNS search function keeps searching in the background. 

**Actual results:** <!-- what did you see? -->
Getting an error from inside the flutter `multicast_dns` package 



<details>
<summary>
</summary>

<!--
      Please create a minimal reproducible sample that shows the problem
      and attach it below between the lines with the backticks.

      To create it you can use `flutter create bug` command and update the `main.dart` file.

      Alternatively, you can use https://dartpad.dev/
      which is capable of creating and running small Flutter apps.

      Without this we will unlikely be able to progress on the issue, and because of that
      we regretfully will have to close it.
-->

```dart
import 'package:network_tools/network_tools.dart';

Future<void> main(List<String> arguments) async {
  await MdnsSearchDevices().searchMdnsDevices();
}


class MdnsSearchDevices {
  Future<void> searchMdnsDevices() async {
    while (true) {
      for (ActiveHost activeHost in await MdnsScanner.searchMdnsDevices(
        forceUseOfSavedSrvRecordList: true,
      )) {}
      DateTime now = DateTime.now();
      print('timestamp: ${now.hour}:${now.minute}.${now.second}');
    }
  }
}

```

</details>

<details>
  <summary>Logs</summary>

<!--
      Run your application with `flutter run --verbose` and attach all the
      log output below between the lines with the backticks. If there is an
      exception, please see if the error message includes enough information
      to explain how to solve the issue. If there is a crash, please include
      the entirety of the crash log including the backtrace.
-->


```dart
Unhandled exception:
SocketException: Failed to create datagram socket (OS Error: Too many open files, errno = 24), address = , port = 5353
#0      _NativeSocket.bindDatagram (dart:io-patch/socket_patch.dart:1015:7)
<asynchronous suspension>
#1      MDnsClient.start (package:multicast_dns/multicast_dns.dart:135:40)
<asynchronous suspension>
#2      MdnsScanner._findingMdnsWithAddress (package:network_tools/src/mdns_scanner/mdns_scanner.dart:72:5)
<asynchronous suspension>
```

<!--
     Run `flutter analyze` and attach any output of that command below.
     If there are any analysis errors, try resolving them before filing this issue.
-->

```
```

<!-- Finally, paste the output of running `flutter doctor -v` here. -->

```
It is dart native so not relevant 
```

</details>


<!--
      Consider also attaching screenshots and/or videos to better
      illustrate the issue.

      You can upload them directly on GitHub.
      Beware that video file size is limited to 10MB.
-->

The project is running inside a Linux arm machine, dart version `Dart SDK version: 2.18.2 (stable) (Tue Sep 27 13:24:11 2022 +0200) on "linux_arm"` mDNS package version `multicast_dns: ^0.3.2+1` that is being used from within [network_tools](https://github.com/osociety/network_tools/tree/main/network_tools) package.

I think it happening in my arm device first is because of the small ram 1gb so it will take much longer to reproduce on a 8+gb ram x64 computer