title: Python and ZeroMQ subscriber acknowledgement to publisher
body: <p>I am trying to get an acknowledgement from my subscriber back to my publisher using ZeroMQ in Python.</p>
  
  <p>I tried a few code examples, using a <code>zmq.PUSH</code> and <code>zmq.PULL</code> code sequence, but to no avail.</p>
  
  <p>My code as it stands:</p>
  
  <p><strong><code>PUB_SERVER.PY</code></strong></p>
  
  <pre><code>import zmq
  import random
  import sys
  import time
  
  port = "5556"
  if len( sys.argv ) &gt; 1:
     port =  sys.argv[1]
     int( port )
  
     context = zmq.Context()
     socket  = context.socket( zmq.PUB )
     socket.bind( "tcp://*:%s" % port )
  
     while True:
        # topic = random.randrange( 9999, 10005 )
        topic       = 10000
        messagedata = random.randrange( 1, 215 ) - 80
        print        "%d %d" % ( topic, messagedata )
        socket.send( "%d %d" % ( topic, messagedata ) )
        time.sleep( 1 )
  </code></pre>
  
  <p><strong><code>SUB_CLIENT.PY</code></strong></p>
  
  <pre><code>import sys
  import zmq
  
  port = "5556"
  if len( sys.argv ) &gt; 1:
     port =  sys.argv[1]
     int( port )
  
     if len( sys.argv ) &gt; 2:
        port1   =  sys.argv[2]
        int( port1 )
  
        # Socket to talk to server
        context = zmq.Context()
        socket  = context.socket( zmq.SUB )
  
        print "Collecting updates from weather server..."
        socket.connect( "tcp://192.168.0.21:%s" % port )
  
  if len( sys.argv ) &gt; 2:
     socket.connect(    "tcp://192.168.0.21:%s" % port1 )
  
     # Subscribe to zipcode, default is NYC, 10001
     topicfilter = "10000"
     socket.setsockopt( zmq.SUBSCRIBE, topicfilter )
  
     # Process 5 updates
     total_value = 0
     for update_nbr in range( 5 ):
        string = socket.recv()
        topic, messagedata = string.split()
        total_value += int( messagedata )
        print topic, messagedata
  
     print "Average messagedata value for topic '%s' was %dF" % ( topicfilter, total_value / update_nbr )
  </code></pre>
  
  <p>That code gives me the output of the server in one SSH window (on a Parallella), and the received filtered messages of the client in another SSH window (on a RaspberryPi) which is working great.</p>
  
  <p>Where I am lost is, once the client has gotten a filtered message from the server, <strong>how would it acknowledge</strong> that filtered message being received, and then have the server log those acknowledged messages?</p>
  
  <p>Eventually, I'd want to do some intelligent decision making of sending a file to the subscriber who acknowledges.</p>