Created
April 1, 2014 17:48
-
-
Save amckinley/9919309 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# 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