As it stands, the discovery mechanism is interleaved with the advertising which means that, if we're waiting to discover something which hasn't yet been advertised, we won't hear it advertised! Possible solutions (all of which must work on 2.7 & 3.3+) include:
two threads, one for advertising, one for discovery
two REQ/REP sockets, one for discovery request, one for discovery response
some other kind of asynchronous event loop within the existing discovery thread.
As it stands, the discovery mechanism is interleaved with the advertising which means that, if we're waiting to discover something which hasn't yet been advertised, we won't hear it advertised! Possible solutions (all of which must work on 2.7 & 3.3+) include: