36 lines
629 B
Python
36 lines
629 B
Python
|
# 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())
|