Skip to content

Instantly share code, notes, and snippets.

@ixaxaar
Created September 27, 2014 08:49
Show Gist options
  • Save ixaxaar/c10af2f26320edbd5541 to your computer and use it in GitHub Desktop.
Save ixaxaar/c10af2f26320edbd5541 to your computer and use it in GitHub Desktop.
A simple zeromq PUSH-PULL streamer device
#!/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