old_contents: # http://learning-0mq-with-pyzmq.readthedocs.org/en/latest/pyzmq/patterns/pubsub.html
  
  import random
  import sys
  import time
  
  import zmq
  
  port = "5556"
  if len(sys.argv) > 1:
      port = sys.argv[1]
      int(port)
  
  context = zmq.Context()
  socket = context.socket(zmq.PUB)
  socket.bind("tcp://*:{}".format(port))
  
  while True:
      topic = random.randrange(9999, 10005)
      messagedata = random.randrange(1, 215) - 80
      print(topic, messagedata)
      socket.send_string("%d %d" % (topic, messagedata))
      time.sleep(1)
  
new_contents: # http://learning-0mq-with-pyzmq.readthedocs.org/en/latest/pyzmq/patterns/pubsub.html
  
  import random
  import sys
  import time
  
  import zmq
  
  port = "5556"
  if len(sys.argv) > 1:
      port = sys.argv[1]
      int(port)
  
  context = zmq.Context()
  socket = context.socket(zmq.PUB)
  socket.bind("tcp://*:{}".format(port))
  
  while True:
      topic = random.randrange(9999, 10005)
      messagedata = random.randrange(1, 215) - 80
      print(topic, messagedata)
      socket.send_string("{} {}".format(topic, messagedata))
      time.sleep(1)
  
subject: Update exercises/chat/online_examples/pub_server.py