Pieter Hintjens wrote:
On Tue, Mar 26, 2013 at 10:09 PM, Anoop Karollil
<[email protected]> wrote:
And
yes, like you said, the send after connect succeeds if there is a pause in
between.
The send should work immediately after connect, which creates a pipe
at once. It's the bind that's troublesome.
I do see the send after connect failing if it is done immediately after,
and it succeeding if there is a pause in between.
Please see the example python programs. Starting the broker first (which
binds and does a receive), and then the client after (which connects and
sends), results in the client send failing, unless there is a pause
after the connect.
If you uncomment the sleep in client.py, it works without failure. If
you don't, it will fail for a while and then succeed.
Thanks,
Anoop
import zmq
broker_uri = "tcp://127.0.0.1:20000"
context = zmq.Context()
broker = context.socket(zmq.ROUTER)
broker.setsockopt(zmq.IDENTITY, "BROKER")
broker.setsockopt(zmq.ROUTER_BEHAVIOR, 1)
broker.bind(broker_uri)
parts = broker.recv_multipart()
print(parts)
import zmq
import time
broker_uri = "tcp://127.0.0.1:20000"
context = zmq.Context()
client = context.socket(zmq.ROUTER)
client.setsockopt(zmq.IDENTITY, "CLIENT")
client.setsockopt(zmq.ROUTER_BEHAVIOR, 1)
client.connect(broker_uri)
#time.sleep(1)
while True:
try:
client.send_multipart(["BROKER", "Hello"])
except zmq.error.ZMQError, e:
print("Error: %s" % e)
else:
print("Success!")
break
_______________________________________________
zeromq-dev mailing list
[email protected]
http://lists.zeromq.org/mailman/listinfo/zeromq-dev