I have done a sample ZeroMQ PGM multicast application and it is working fine.
But reply handling is not working. Is this correct approach or not?
If yes - how to do any reply from a Receiver to the Sender?
Sender:
std::string msg = "hello";
socket->send(msg.c_str(),msg.length(),0);
socket->recv(reply); // Can we do this?
Receiver:
char msg[100] = {0};
std::string reply = "Succ";
socket->recv(msg,100,0);
socket->send(reply.c_str(),reply.length(),0); // Can we do this?
Yes, the ZeroMQ pgm://
transport-class does not support this.
No, we cannot do this. Neither a .send()
on a SUB
side, or a .recv()
on a PUB
side.
ZeroMQ API Specification says:
Thepgm
andepgm
transports can only be used with theZMQ_PUB
andZMQ_SUB
socket types.
ZMQ_SUB
archetype does not permit any .send()
method.
ZMQ_PUB
archetype does not permit any .recv()
method.
One has to add also another socket, most probably using a tcp://
transport class, over which a feedback signalling may take place.
ZeroMQ's reverse .bind()
/.connect()
mechanics are a common practice for doing this in an unstructured, formally uncontrolled / configuration-policy unenforced distributed computing infrastructures.