Re: [zeromq-dev] zmq_send blocks after zmq_bind and before other side connects
On Thu, Aug 23, 2012 at 7:30 AM, Dmitrijs Palcikovs dim...@gmail.com wrote: If zmq_bind is replaced with zmq_connect then it doesn't block. I would expect zmq_send to buffer outgoing messages in both scenarios (bind and connect). This behavior doesn't seem to be documented anywhere... To be honest I consider this to be an issue that needs fixing. It breaks the symmetry of the API and forces us to understand internal constraints of the library. I'll tag it in the issue tracker. -Pieter ___ zeromq-dev mailing list zeromq-dev@lists.zeromq.org http://lists.zeromq.org/mailman/listinfo/zeromq-dev
[zeromq-dev] zmq_send blocks after zmq_bind and before other side connects
It seems like zmq_send blocks after zmq_bind and before the other side connects to the endpoint. For example, the following code: void *sock = zmq_socket(ctx, ZMQ_PAIR); zmq_bind(sock, tcp://*:9090); zmq_msg_t msg; zmq_msg_init_size(msg, 5); memcpy(zmq_msg_data(msg), hello, 5); zmq_send(sock, msg); // Blocks until someone connects zmq_msg_close(msg) If zmq_bind is replaced with zmq_connect then it doesn't block. I would expect zmq_send to buffer outgoing messages in both scenarios (bind and connect). This behavior doesn't seem to be documented anywhere (i.e. most of the docs seem to give the impression that bind and connect are similar in this sense), yet this is a significant difference between the two. Can anyone comment on why this is the behavior for bind? ___ zeromq-dev mailing list zeromq-dev@lists.zeromq.org http://lists.zeromq.org/mailman/listinfo/zeromq-dev
Re: [zeromq-dev] zmq_send blocks after zmq_bind and before other side connects
On Wednesday, August 22, 2012 10:30:55 PM Dmitrijs Palcikovs wrote: It seems like zmq_send blocks after zmq_bind and before the other side connects to the endpoint. For example, the following code: void *sock = zmq_socket(ctx, ZMQ_PAIR); zmq_bind(sock, tcp://*:9090); zmq_msg_t msg; zmq_msg_init_size(msg, 5); memcpy(zmq_msg_data(msg), hello, 5); zmq_send(sock, msg); // Blocks until someone connects zmq_msg_close(msg) If zmq_bind is replaced with zmq_connect then it doesn't block. I would expect zmq_send to buffer outgoing messages in both scenarios (bind and connect). This behavior doesn't seem to be documented anywhere (i.e. most of the docs seem to give the impression that bind and connect are similar in this sense), yet this is a significant difference between the two. Can anyone comment on why this is the behavior for bind? This is a non-obvious behavior of zeromq that I ran into as well. It was added to the FAQ: http://www.zeromq.org/area:faq Why do I see different behavior when I bind a socket versus connect a socket? Justin ___ zeromq-dev mailing list zeromq-dev@lists.zeromq.org http://lists.zeromq.org/mailman/listinfo/zeromq-dev