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 [email protected] http://lists.zeromq.org/mailman/listinfo/zeromq-dev
