Created
October 19, 2013 14:55
-
-
Save BlaShadow/7056978 to your computer and use it in GitHub Desktop.
Simple Zeromq Client and Server python REQ/REP Pattern.
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
#! python | |
import zmq | |
context = zmq.Context() | |
socket = context.socket(zmq.REQ) | |
socket.connect('tcp://127.0.0.1:6000') | |
for x in xrange(1,10): | |
message = 'Message ' + str(x) | |
title = raw_input("New message> ") | |
socket.send(title + " > " + message) | |
server = socket.recv() | |
print server |
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
#! python | |
import zmq | |
context = zmq.Context() | |
socket = context.socket(zmq.REP) | |
port = 6000 | |
socket.bind( 'tcp://127.0.0.1:{}'.format(port) ) | |
while True: | |
print 'Watting for messages running on',port | |
message = socket.recv() | |
print 'new Message' | |
socket.send('Fron server '+ message) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment