Skip to content

Instantly share code, notes, and snippets.

@jiminoc
Created June 12, 2012 18:43
Show Gist options
  • Save jiminoc/2919325 to your computer and use it in GitHub Desktop.
Save jiminoc/2919325 to your computer and use it in GitHub Desktop.
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