You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
box-o-sand/zeromq/hwserver.py

36 lines
629 B

# vim:fileencoding=utf-8
from __future__ import print_function
import sys
import time
import zmq
BIND_ADDR = 'tcp://*:5555'
def main():
context = zmq.Context(1)
responder = context.socket(zmq.REP)
print('Binding server to {}'.format(BIND_ADDR))
responder.bind(BIND_ADDR)
print('Starting loop.')
try:
while True:
responder.recv()
print('Received Hello')
time.sleep(0.25)
responder.send("World")
except KeyboardInterrupt:
responder.close()
context.term()
return 0
if __name__ == '__main__':
sys.exit(main())