Because I can't find the button to add a new ticket with these new SourceForge updates...
I'm trying to implement an iterator which returns services as soon as they are known and then terminates at the timeout.
So we add a listener:
But the problem is that sometimes the jmmDNS object already knows about some services which match the service type and these are not fired to the listener. I think they should be.
The closest thing I have to a workaround is:
This seems to work on Windows but not on Mac OS X. On the latter, the timeout of 0 appears to cause some of the background tasks to be cancelled, so services spuriously disappear from the list.
So for now I will have to call list() with my maximum timeout, which means I am no longer returning an iterator which returns the entries as they are discovered.
Any of the following would be an improvement for me:
(a) Make a 0 timeout not cancel the background tasks if the timeout is exceeded (i.e., make it return the already-known services immediately.
(b) Make a separate method to return the already-known services.
(c) Make it so that addServiceListener() fires information about the already-known services as well as those discovered after adding the listener.
Edit: Actually, even using the maximum timeout doesn't work. The entire timeout is expended on the first JmDNS object and then subsequent ones are cancelled.
The bug was that:
(1) list() returns no records if called with a short timeout.
(2) Calling list() somehow make it so that addServiceListener() receives no records either.
I finally found that the workaround is just to call addServiceListener() because it does return existing records, although this didn't seem to be documented at the time I was last investigating the issue.