[zeromq-dev] UDP message with zeromq 2.0beta

Guo, Yanchao Yanchao.Guo at sac.com
Thu Jan 21 08:37:41 CET 2010

Hi Martin, I am trying the simple test program for udp, and I setup a simple pair of server/client on my machine. Out of 10 messages, I only get like 4 or 5 messages successfully received. I understand that UDP doesn't guarantee that all message to be delivered , but I think the success rate is just too low. Did you see the same for your testing? 

The attached is my source code (which is basically copy of sample code form zeromq site).

#include <zmq.hpp>

int main ()
        zmq::context_t ctx (1, 1);
zmq::socket_t s (ctx, ZMQ_PUB);
long rate = 10000; //  Limit the throughput to 10Mb/s.
s.setsockopt (ZMQ_RATE, &rate, sizeof (rate));
s.connect ("udp://eth0;");
zmq::message_t msg (10);
memcpy (msg.data (), "xy.z\x00" "ABCDE", 10);
s.send (msg);
        return 1;

#include <zmq.hpp>
#include <iostream>
int main ()
        zmq::context_t ctx (1, 1);
zmq::socket_t s (ctx, ZMQ_SUB);
s.connect ("udp://eth0;");
s.setsockopt (ZMQ_SUBSCRIBE, "", 0);
zmq::message_t msg;
s.recv (&msg);
std::cout << "received\n";
std::string abc((char*)msg.data(), msg.size());
std::cout << abc << std::endl;
    return 0;

DISCLAIMER: This e-mail message and any attachments are intended solely for the use of the individual or entity to which it is addressed and may contain information that is confidential or legally privileged. If you are not the intended recipient, you are hereby notified that any dissemination, distribution, copying or other use of this message or its attachments is strictly prohibited. If you have received this message in error, please notify the sender immediately and permanently delete this message and any attachments. 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20100121/0500d9c4/attachment.htm>

More information about the zeromq-dev mailing list