0
votes

I am having problems with the Windows.Devices.Enumeration and its DeviceWatcher with DN-SD with C++/WinRT. I have 2 network cards in my machines and only those services on machines connected via the first card are found.

This happens both in my own test program and when I extend the DeviceEnumeration sample program in Microsoft's "Windows Universal Samples" to include DNS-SD, e.g. add to DeviceSelectorChoices in Samples/DeviceEnumerationAndPairing/cpp/DisplayHelpers.h

static property DeviceSelectorInfo^ Dnssd
{
    DeviceSelectorInfo^ get();
}

and to Samples/DeviceEnumerationAndPairing/cpp/DisplayHelpers.cpp insert

DeviceSelectorInfo^ DeviceSelectorChoices::Dnssd::get()
{
    return ref new DeviceSelectorInfo("DNS-SD",
        DeviceClass::All,
        "System.Devices.AepService.ProtocolId:=\"{4526e8c1-8aac-4153-9b16-55e86ada0e54}\" "
        "AND System.Devices.Dnssd.ServiceName:=\"_myservice._tcp\"",
        DeviceInformationKind::AssociationEndpointService);
}

to Samples/DeviceEnumerationAndPairing/cpp/DisplayHelpers.cpp and update the method:

IVectorView<DeviceSelectorInfo^>^ DeviceSelectorChoices::DeviceWatcherSelectors::get()
{
    Vector<DeviceSelectorInfo^>^ selectors = ref new Vector<DeviceSelectorInfo^>(begin(CommonDeviceSelectors), end(CommonDeviceSelectors));
    selectors->Append(Dnssd);
    ...

Then compile and run and select DNS-SD from the device watcher - it only finds services on machines with a connection on the first network interface's subnet, even if it has a connection on the second's subnet. But it doesn't list any services that are running on machines only on the second network.

Using the dns-sd command line tool finds all the advertised services on both networks:

dns-sd -B _myservice._tcp

I have tried many variations on the AQSFilter thinking that it is perhaps not defaulting to using both network interfaces - e.g. using System.Devices.Dnssd.NetworkAdapterId - but no joy.

I guess its also poossible its something lower down in Windows than the device enumeration API..?

Edit the question and show: your mcve] so those interested in helping you will have context; any research you have done.user1531971
Thanks for the tip @jdv - have updated accordingly.Buttered Monkey