[zeromq-dev] How to use the PGM

Alexander Zhitlenok AZhitlenok at geneva-trading.com
Tue Sep 3 16:12:06 CEST 2013


Pgm SUB & PUB apps don't work on the same box, you should use 2. Accordingly, the addresses interface parts should be different, in our case they are the boxes' IPs (ask your sys admin).
We use Epgm broadcasting (one-to-many) schema with no problem (Win7\64\VS2010), however, when we used many-to-one schema we faced with insurmountable obstacles. See my mail ("multicast messages corrupted").


From: zeromq-dev-bounces at lists.zeromq.org [mailto:zeromq-dev-bounces at lists.zeromq.org] On Behalf Of ???
Sent: Tuesday, September 03, 2013 1:37 AM
To: zeromq-dev at lists.zeromq.org
Subject: [zeromq-dev] How to use the PGM

  I use the PUB-SUB pattern in my program. When I use the TCP protocol, It works fine. But I change to the PGM protocol(using the same code), I can send data, but can't receive any data. Following are the Code

//Sender Code
    ctx = zmq_init (1);
    s = zmq_socket (ctx, ZMQ_PUB);
    rc = zmq_bind (s, "tcp://");
    for (i = 0; i != 1000; i++) {
        rc = zmq_msg_init_size (&msg, 50);
        unsigned char *msg_point = (unsigned char *)zmq_msg_data(&msg);
        memcpy(msg_point, (unsigned char *)&order, sizeof(unsigned int));
        rc = zmq_sendmsg (s, &msg, 0);
        rc = zmq_msg_close (&msg);
    rc = zmq_close (s);
    rc = zmq_term (ctx);

//Receive Code
    ctx = zmq_init (1);
    s = zmq_socket (ctx, ZMQ_SUB);
    rc = zmq_connect (s, "tcp://");
    rc = zmq_setsockopt (s, ZMQ_SUBSCRIBE, "", 0);
    rc = zmq_msg_init_size (&msg, message_size);
    while(1) {
        rc = zmq_recvmsg (s, &msg, 0);
        unsigned char *msg_point = (unsigned char *)zmq_msg_data(&msg);
        memcpy((unsigned char *)&order, msg_point, sizeof(unsigned int));
        print("Get size=%d order=%d\n", rc,order);
    rc = zmq_close (s);
    rc = zmq_term (ctx);

If I change "tcp://" to "pmg://;", it doesn't work. Where do I make a mistake?
My platform is Windows 7 64bit and Using VS 2008. The PGM library download from http://miru.hk/openpgm/

Liwei Chour in OFFICe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20130903/e4e7ca2f/attachment.htm>

More information about the zeromq-dev mailing list