Open xmlspyspring opened 8 months ago
I know what the reason is, but I can't change it. This is caused by a bug in the multicast_dns.
The file in this library multicast_dns - 0.3.2 + 6\ lib\ multicast_dns.dart line 63 gets all NetInterfaces, but I have two NetworkInterfaces that are closed, so using a socket to connect the two NetInterfaces makes an error.
Future<Iterable<NetworkInterface>> allInterfacesFactory(
InternetAddressType type) {
return NetworkInterface.list( // ---> here
includeLinkLocal: true,
type: type,
includeLoopback: true,
);
}
I found a solution, but I don't know if it's right.
in file lib/src/services/impls/mdns_scanner_service_impl.dart line 73 change
await client.start();
to
await client.start(interfacesFactory: (InternetAddressType type){
return NetworkInterface.list(
includeLinkLocal: false, // old is true
type: type,
includeLoopback: true,
);
},);
or
await client.start(interfacesFactory: (InternetAddressType type){
return NetworkInterface.list(
includeLinkLocal: true,
type: type,
includeLoopback: true,
).then((List<NetworkInterface> list){
list.removeWhere((item){
if(ping item is not ok) return true; // remove this item
return false; // ping item is ok
});
return list;
});
},);
includeLinkLocal: false
will exclude interfaces for everyone. You have 2 interfaces closed but others can have open. If we can determine if a network interface is not closed then we fix this. Probably you can to clone this repo and raise a PR for the fix.
But I don't think that this is the right place to fix it. If we can fix it in package multicast_dns
then it would be better. Can you open the same issue in multicast_dns
also and let's see if they can fix it.
I ran example/lib/scan/mdns_scan.dart and got the following error:
My Environment: windows 10 chinese