-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FEAT(client, server): use native mDNS/DNS-SD API on Windows, if available #4494
FEAT(client, server): use native mDNS/DNS-SD API on Windows, if available #4494
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few more documentation comments would be nice as well :)
ca3b5f8
to
c828996
Compare
Sorry for the many force-pushes. Interestingly, the error you mentioned only happened with the x86 build, I had to specify However, there's now an issue I can reproduce locally: Zeroconf.cpp.obj : error LNK2019: unresolved external symbol _DnsServiceConstructInstance referenced in function "public: bool __thiscall Zeroconf::registerService(class BonjourRecord const &,unsigned short)" (?registerService@Zeroconf@@QAE_NABVBonjourRecord@@G@Z)
Zeroconf.cpp.obj : error LNK2019: unresolved external symbol _DnsServiceFreeInstance referenced in function "protected: static void __stdcall Zeroconf::callbackRegisterComplete(unsigned long,void *,struct _DNS_SERVICE_INSTANCE *)" (?callbackRegisterComplete@Zeroconf@@KGXKPAXPAU_DNS_SERVICE_INSTANCE@@@Z)
Zeroconf.cpp.obj : error LNK2019: unresolved external symbol _DnsServiceRegister referenced in function "public: bool __thiscall Zeroconf::registerService(class BonjourRecord const &,unsigned short)" (?registerService@Zeroconf@@QAE_NABVBonjourRecord@@G@Z)
Zeroconf.cpp.obj : error LNK2019: unresolved external symbol _DnsServiceDeRegister referenced in function "public: bool __thiscall Zeroconf::unregisterService(void)" (?unregisterService@Zeroconf@@QAE_NXZ)
Zeroconf.cpp.obj : error LNK2019: unresolved external symbol _DnsServiceRegisterCancel referenced in function "public: bool __thiscall Zeroconf::unregisterService(void)" (?unregisterService@Zeroconf@@QAE_NXZ) The symbols appear to be present in the x86 |
I can reproduce with https://github.com/andrewtj/windns-dnssd-exercise: windns dnssd exercise.obj : error LNK2019: unresolved external symbol _DnsServiceConstructInstance referenced in function _main
windns dnssd exercise.obj : error LNK2019: unresolved external symbol _DnsServiceFreeInstance referenced in function "void __stdcall ResolveCallback(unsigned long,void *,struct _DNS_SERVICE_INSTANCE *)" (?ResolveCallback@@YGXKPAXPAU_DNS_SERVICE_INSTANCE@@@Z)
windns dnssd exercise.obj : error LNK2019: unresolved external symbol _DnsServiceRegister referenced in function _main
windns dnssd exercise.obj : error LNK2019: unresolved external symbol _DnsServiceDeRegister referenced in function _main @andrewtj Did you perhaps try to build the project for x86 back when you worked on it? If yes, did it link successfully? I would like to know whether it's a long standing issue or one that appeared in a recent version of the SDK. |
@davidebeatrici I never tried x86 and fwiw I got the impression the API isn't finished. |
The MinGW build fails with
Additionally I think that your last 2 commits should actually only be a single commit since they are about the same thing (pretty much) 🤔 |
Issue reported: https://developercommunity.visualstudio.com/content/problem/1191345/some-dns-api-functions-cause-lnk2019-errors-in-32.html @andrewtj I read your blog post (https://andrewtj.com/log/dnssd-apis).
This is indeed a limitation, however in our case it's not a big issue: closing the connect dialog and opening it again forces a refresh. |
I think that might get out of sync if there's a naming conflict (due to duelling clients, bugs, or infrastructure issues). |
I agree. However, doesn't Avahi/mDNSResponder retrieve the local hostname too? |
c828996
to
2099a95
Compare
They're generally configured with the local hostname but they can be configured with another name and will change their name if there's a conflict. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The x86 build still fails with
Creating library src\murmur\murmur.lib and object src\murmur\murmur.exp
Zeroconf.cpp.obj : error LNK2019: unresolved external symbol _DnsServiceConstructInstance referenced in function "public: bool __thiscall Zeroconf::registerService(class BonjourRecord const &,unsigned short)" (?registerService@Zeroconf@@QAE_NABVBonjourRecord@@G@Z)
Zeroconf.cpp.obj : error LNK2019: unresolved external symbol _DnsServiceFreeInstance referenced in function "protected: static void __stdcall Zeroconf::callbackRegisterComplete(unsigned long,void *,struct _DNS_SERVICE_INSTANCE *)" (?callbackRegisterComplete@Zeroconf@@KGXKPAXPAU_DNS_SERVICE_INSTANCE@@@Z)
Zeroconf.cpp.obj : error LNK2019: unresolved external symbol _DnsServiceRegister referenced in function "public: bool __thiscall Zeroconf::registerService(class BonjourRecord const &,unsigned short)" (?registerService@Zeroconf@@QAE_NABVBonjourRecord@@G@Z)
Zeroconf.cpp.obj : error LNK2019: unresolved external symbol _DnsServiceDeRegister referenced in function "public: bool __thiscall Zeroconf::unregisterService(void)" (?unregisterService@Zeroconf@@QAE_NXZ)
Zeroconf.cpp.obj : error LNK2019: unresolved external symbol _DnsServiceRegisterCancel referenced in function "public: bool __thiscall Zeroconf::unregisterService(void)" (?unregisterService@Zeroconf@@QAE_NXZ)
murmur.exe : fatal error LNK1120: 5 unresolved externals
And one more thing: According to our commit guidelines, multiple scopes are to be separated using a comma and not a slash. Therefore it should be REFAC(client, server)
☝️
Ah, I see. Thank you for the explanation. @Krzmbrzl Renamed the PR, I'll also rename the commit as soon as the x86 build issue is fixed (see the Microsoft Developer Community issue I linked in #4494 (comment) for updates). |
76947b9
to
732b35d
Compare
…3rdparty This should make it more clear that we don't include Bonjour-related stuff in our project. We use external libraries depending on the OS. For compatibility, the server option is still called "bonjour". We should probably add a new option called "zeroconf" and then handle the old one if present in the configuration file.
732b35d
to
44aacb0
Compare
…able This allows: - The client to find servers advertized via zeroconf without the need for Bonjour to be installed. - The server to advertize itself via zeroconf without the need for Bonjour to be installed. The Win32 API was introduced in the version 10.0.18362.0 (1903/19H1) of Windows SDK. Before that, only the UWP interface was available (introduced in Windows 10 1507). This commit was successfully tested on Windows 10 1809, which probably means that the API can be used on previous versions as well. Even if that isn't the case, it's not a problem: if the code fails to load the required symbols, it falls back to Bonjour. "Q_OS_WIN64" is used instead of "Q_OS_WIN" because of an issue that appears when certain DNS functions are used in an x86 (32 bit) build: https://developercommunity.visualstudio.com/content/problem/1191345/some-dns-api-functions-cause-lnk2019-errors-in-32.html This means that until the issue is fixed we can safely use the native mDNS-DNS-SD API only on x86_64 (64 bit).
44aacb0
to
ee731f8
Compare
Turns out the issue is caused by a bug in the Windows SDK: missing https://developercommunity.visualstudio.com/comments/1194102/view.html |
This allows:
The Win32 API was introduced in the version
10.0.18362.0
(1903/19H1) of Windows SDK. Before that, only the UWP interface was available (introduced in Windows 10 1507).This commit was successfully tested on Windows 10 1809, which probably means that the API can be used on previous versions as well.
Even if that isn't the case, it's not a problem: the code checks whether the functions we need are exported. If they're not, it falls back to Bonjour.
Q_OS_WIN64
is used instead ofQ_OS_WIN
because of an issue that appears when certain DNS functions are used in an x86 (32 bit) build: https://developercommunity.visualstudio.com/content/problem/1191345/some-dns-api-functions-cause-lnk2019-errors-in-32.htmlThis means that until the issue is fixed we can safely use the native mDNS-DNS-SD API only on x86_64 (64 bit).