'DnsServiceRegister API issue
I'm trying to use the Windows 10+ API DnsServiceRegister to register a web server to be discoverable.
DNS_SERVICE_REGISTER_REQUEST rd = {};
DNS_SERVICE_INSTANCE di = {};
rd.pServiceInstance = &di;
rd.unicastEnabled = 0;
di.pszInstanceName = L"Remote Control._http._tcp.local";
di.pszHostName = L"192.168.10.6";
IP4_ADDRESS i4 = {};
InetPton(AF_INET, L"192.168.10.6", (void*)&i4);
di.ip4Address = &i4;
di.wPort = (WORD)12345;
rd.Version = DNS_QUERY_REQUEST_VERSION1;
rd.pRegisterCompletionCallback = [](DWORD Status,
PVOID pQueryContext,
PDNS_SERVICE_INSTANCE pInstance)
{
nop();
};
DnsServiceRegister(&rd, 0);
The call succeeds (return value DNS_REQUEST_PENDING as per documentation) and after a while, my callback is called with status = 0 (Success?). However, no UPnP tools detect my service. When I set unicast to 1, status is 9002 (error).
What am I missing in using this API?
Edit: When the callback is called, the pInstance parameter there points to a DNS_SERVICE_INSTANCE with ip4Address and ip6Address null pointers. Why?
Edit: It's discoverable by using DnsServiceBrowse(). But UPnP scan tools don't discover it.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
