[zeromq-dev] proper usage fan-out model

Alexander Voron voron.alexander at gmail.com
Mon Aug 20 23:37:53 CEST 2012


Can I use the following approach?

    zmq::context_t context (1);
    zmq::socket_t socket (context, ZMQ_REQ);

    std::string input = "abc";
    int messageLength = input.length();
    zmq::message_t request (messageLength);
    memcpy ((void *) request.data (), input.c_str(), messageLength);

    socket.connect ("tcp://192.168.0.1:8080");
    socket.send (request);

    socket.connect ("tcp://192.168.0.2:8080");
    socket.send (request);

    socket.connect ("tcp://192.168.0.3:8080");
    socket.send (request);

...

Or is there any correct way to send the same message to multiple
endpoints? Endpoints are about 2 - 6.

As I understand PUB-SUB pattern is good for such tasks but I have to
communicate through many networks without proxy.



More information about the zeromq-dev mailing list