[zeromq-dev] i can't see what i am doing wrong

Andrew Hume andrew at research.att.com
Tue Jul 6 00:31:19 CEST 2010


folks,

	i am doing a simple case and can't see my error:

in process a:
         ctxt = zmq_init(1, 5, 0);
         q = zmq_socket(ctxt, ZMQ_PUB);
         sprintf(buf, "tcp://%s:%s", machine, port);
         n = zmq_connect(q, buf);

         for(n = 0; n < 2050; n++){
                 get_goo(loc, &data, &len);
                 zmq_msg_init_size(&msg, len);
                 memcpy(zmq_msg_data(&msg), data, len);
                 m = zmq_send(q, &msg, 0);
                 assert(m == 0);
         }
         zmq_term(ctxt);
         exit(0);

in process b:
         ctxt = zmq_init(1, 10, 0);
         q = zmq_socket(ctxt, ZMQ_SUB);
         sprintf(buf, "tcp://*:%s", port);
         n = zmq_bind(q, buf);
	assert(n == 0);
         n = zmq_setsockopt(q, ZMQ_SUBSCRIBE, 0, 0);
	assert(n == 0);

         for(n = 0; ; n++){
                 zmq_msg_init(&msg);
                 m = zmq_recv(q, &msg, 0);
		assert(m == 0);
                 zmq_msg_close(&msg);
                 if((n%100) == 99){
                         printf("got %d packets\n", n+1);
                         sleep(1);
                 }
         }

the problem:
	process b doesn't always see all 2050 messages from process a.
maybe 5% it does. sometimes, 1300 get thru, other times, 2000.
nothing i've checked returns an error. i'm running 2.0.6 on redhat 5.4.
	is my code in error? or am i misunderstanding something?

thanks

------------------
Andrew Hume  (best -> Telework) +1 732-886-1886
andrew at research.att.com  (Work) +1 973-360-8651
AT&T Labs - Research; member of USENIX and LOPSA



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20100705/3ac33ef4/attachment.htm>


More information about the zeromq-dev mailing list