Skip to content

Instantly share code, notes, and snippets.

@amckinley
Created April 1, 2014 17:48
Show Gist options
  • Save amckinley/9919309 to your computer and use it in GitHub Desktop.
Save amckinley/9919309 to your computer and use it in GitHub Desktop.
# server
import zmq
zmq_context = zmq.Context()
pub_socket = zmq_context.socket(zmq.PUB)
pub_socket.connect(subpub.SUB_ADDR)
while True:
pub_socket.send_multipart((str(topic), str(flask.request.data)))
# client
import zmq
def main():
addr = "tcp://173.245.57.89:2212"
zmq_context = zmq.Context().instance()
sub_socket = zmq_context.socket(zmq.SUB)
sub_socket.connect(addr)
sub_socket.setsockopt(zmq.SUBSCRIBE, '')
while True:
data = sub_socket.recv_multipart()
print data, type(data)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment