Filled in a python-based Hello World server
This commit is contained in:
parent
31f56408d7
commit
fc056f0d8b
35
zeromq/hwserver.py
Normal file
35
zeromq/hwserver.py
Normal file
@ -0,0 +1,35 @@
|
||||
# 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())
|
Loading…
Reference in New Issue
Block a user