from __future__ import print_function
import zmq
import time

ADDR='tcp://127.0.0.1:11155'

ctx = zmq.Context()
srv = ctx.socket(zmq.REP)
srv.bind(ADDR)
#srv.setsockopt(zmq.RCVTIMEO, 3000);


while True:
  try:
    msg = srv.recv()
  except Exception as e:
    print('zmq socket revc timedout:', e)
  else:
    print('client says: %s' % msg)
    srv.send('hi from server')
    
  time.sleep(2)

[((7, 6, 7, 19), 'zmq.Context', 'zmq.Context', ({}, {}), '()', False, 'import zmq\n'), ((22, 2, 22, 15), 'time.sleep', 'time.sleep', ({(22, 13, 22, 14): '(2)'}, {}), '(2)', False, 'import time\n')]