c++ zeromq with pgm crash in joining multicast in windows

18 views Asked by At

I compile zeromq c++ source code with pgm source code in visual code 2019, and get zeromq lib. Then I config my multicast environment, but the program failed in joining multicast. my code is :

    void* context = zmq_ctx_new();
    void* socket = zmq_socket(context, ZMQ_SUB);
    zmq_setsockopt(socket, ZMQ_SUBSCRIBE, "", 0);
    zmq_setsockopt(socket, ZMQ_RATE, &RATE, sizeof(RATE));

    const int32_t RCVBUF_SIZE = 1342177280;
    zmq_setsockopt(socket, ZMQ_RCVHWM, &RCVBUF_SIZE, sizeof(RCVBUF_SIZE));

    const int32_t SNDBUF_SIZE = 1342177280;
    zmq_setsockopt(socket, ZMQ_SNDHWM, &SNDBUF_SIZE, sizeof(SNDBUF_SIZE));
    // example: "epgm://192.168.65.132;224.0.22.1:9210"
    const std::string protocol = "epgm";
    int rc = zmq_connect(
      socket, (protocol + "://" + local_ip + ";" + multicast_addr).c_str());`

When debugging it, I found it failed in :

`int rc = pgm_receiver->init (udp_encapsulation, _addr->address.c_str ()); (from file session_base.cpp)`

continuing the debugging process, it returns -1 here:

`retval = setsockopt (s, recv_level, MCAST_JOIN_GROUP, (const char*)gr, sizeof(struct group_req));(from file sockaddr.c89.c)`

How can I resolve this issue?

the reason and the solution

1

There are 1 answers

0
jinspace On

It is an open bug: https://github.com/zeromq/libzmq/issues/4301. You need to replace SOL_IP with IPPROTO_IP, and re-compile the pgm src.