Created
June 12, 2012 18:43
-
-
Save jiminoc/2919325 to your computer and use it in GitHub Desktop.
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
import zmq | |
context = zmq.Context() | |
# Socket to talk to server | |
print "Connecting to server" | |
socket = context.socket(zmq.REQ) | |
socket.connect ("tcp://127.0.0.1:5559") | |
print 'Client started' | |
poll = zmq.Poller() | |
poll.register(socket, zmq.POLLIN) | |
reqs = 0 | |
while True: | |
for i in xrange(5): | |
sockets = dict(poll.poll(100)) | |
if socket in sockets: | |
if sockets[socket] == zmq.POLLIN: | |
msg = socket.recv() | |
print 'Client received: %s\n' % (msg) | |
del msg | |
reqs = reqs + 1 | |
print 'Req #%d sent..' % (reqs) | |
socket.send('request client1 #%d' % (reqs)) | |
socket.close() | |
context.term() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment