Created
September 27, 2014 08:49
-
-
Save ixaxaar/c10af2f26320edbd5541 to your computer and use it in GitHub Desktop.
A simple zeromq PUSH-PULL streamer device
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import zmq | |
def main(): | |
try: | |
context = zmq.Context(1) | |
# Socket facing clients | |
frontend = context.socket(zmq.PULL) | |
frontend.setsockopt(zmq.LINGER,-1) | |
frontend.bind("tcp://*:8880") | |
# Socket facing services | |
backend = context.socket(zmq.PUSH) | |
backend.setsockopt(zmq.LINGER,-1) | |
backend.bind("tcp://*:8888") | |
dev = zmq.device(zmq.STREAMER, frontend, backend) | |
dev.daemon = False | |
except Exception, e: | |
print e | |
print "bringing down zmq device" | |
finally: | |
pass | |
frontend.close() | |
backend.close() | |
context.term() | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment