I am using the Windows.Networking.ServiceDiscovery.Dnssd API in a UWP project to register a DnssdServiceInstance to broadcast around the network using the following code:
//Service Broadcast
_listener = new StreamSocketListener();
_listener.ConnectionReceived += _listener_ConnectionReceived;
await _listener.BindServiceNameAsync("56788");
string userid = SettingsHelper.GetSetting("userid").ToString();
_service = new DnssdServiceInstance(userid + "._listen._tcp.local",
NetworkInformation.GetHostNames().FirstOrDefault(x => x.Type == HostNameType.DomainName && x.RawName.Contains("local")),
UInt16.Parse(_listener.Information.LocalPort));
await _service.RegisterStreamSocketListenerAsync(_listener);
The service is created just fine but is never removed from the network. I keep seeing all created instances with my DeviceWatcher. Even when disposing and setting the StreamSocketListener to null.
Update: When the computer that created the service is restarted, all the created services are gone.. but not when the application that created the service has shut down
There is no mention in the API of service removal. Is this a bug or did I miss something?
Thanks