[zeromq-dev] zmq_send blocks after zmq_bind and before other side connects

Dmitrijs Palcikovs dimuxa at gmail.com
Thu Aug 23 07:30:55 CEST 2012


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?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20120823/ae540648/attachment.htm>


More information about the zeromq-dev mailing list