title: Get subscriber filter from a ZMQ PUB socket
body: <p>I noticed in the FAQ, in the <a href="http://zeromq.org/area:faq#toc7" rel="noreferrer">Monitoring section</a>, that it's not possible to get a list of connected peers or to be notified when peers connect/disconnect.</p>
  
  <p>Does this imply that it's also not possible to know which topics a PUB/XPUB socket knows it should publish, from its upstream feedback? Or is there some way to access that data?</p>
  
  <p>I know that ZMQ >= 3.0 "<a href="http://zeromq.org/whitepapers:0mq-3-0-pubsub" rel="noreferrer">supports PUB/SUB filtering at the publisher</a>", but what I really want is to filter at my application code, using the knowledge ZMQ has about which topics are subscribed to.</p>
  
  <p>My use-case is that I want to publish info about the status of a robot. Some topics involve major hardware actions, like switching the select lines on an ADC to read IR values. </p>
  
  <p>I have a publisher thread running on the bot that should only do that "read" to get IR data when there are actually subscribers. However, since I can only feed a string into my pub_sock.send, I always have to do the costly operation, even if ZMQ is about to drop that message when there are no subscribers.</p>
  
  <p>I have an implementation that uses a backchannel REQ/REP socket to send topic information, which my app can check in its publish loop, thereby only collecting data that needs to be collected. This seems very inelegant though, since ZMQ must already have the data I need, as evidenced by its filtering at the publisher.</p>
  
  <p>I noticed that in this <a href="http://osdir.com/ml/zermq-development/2012-10/msg00031.html" rel="noreferrer">mailing list message</a>, the OP seems to be able to see subscribe messages being sent to an XPUB socket.</p>
  
  <p>However, there's no mention of how they did that, and I'm not seeing any such ability in the docs (still looking). Maybe they were just using Wireshark (to see upstream subscribe messages to an XPUB socket).</p>