traviscline/gevent-zeromq — Issue #19: REQREP sample
Author: fortunado
Created: 2011-10-25 19:00:34+00:00
State: open

Sorry, I didn't know where else to ask, so I posted my question here:
This example (from sources but without broker) don't work - nothings happening when started:

from gevent import spawn
from gevent_zeromq import zmq

# server
context = zmq.Context()
socket = context.socket(zmq.REP)
socket.connect("tcp://localhost:5560")

def serve(socket):
while True:
message = socket.recv()
print "Received request: ", message
socket.send("World")
server = spawn(serve, socket)

# client
context = zmq.Context()
socket = context.socket(zmq.REQ)
socket.connect("tcp://localhost:5560")

# Do 10 requests, waiting each time for a response
def client():
for request in range(1,10):
socket.send("Hello")
message = socket.recv()
print "Received reply ", request, "[", message, "]"

spawn(client).join()

Is broker required ? Or its a bug/I missed something ? The example with broker works fine.

Thank you.