I'm sorry for this kinda stupid question, but I didn't find any other answer. How can I send a message from ZMQ_DEALER
to ZMQ_REP
?
There is server code:
std::string ans;
zmq::context_t context;
zmq::socket_t socket(context, ZMQ_DEALER);
int port = bind_socket(socket);
std::cout<<port<<std::endl;
std::cout<<"sending\n";
send_message(socket,"test");
std::cout<<"SUCCESS\n";
std::cout<<"trying to get msg from client...\n";
ans=receive_message(socket);
std::cout<<"TOTAL SUCCESS\n";
std::cout<<ans<<std::endl;
close(port);
and there is client code:
zmq::context_t context;
zmq::socket_t socket(context, ZMQ_REP);
std::string recv;
recv=receive_message(socket);
std::cout<<" total successss\n";
send_message(socket,"success");
std::cout<<recv<<std::endl;
Client can't receive message from server. I tried to find something in official ZeroMQ book, and I found this:
"When a
ZMQ_DEALER
socket is connected to aZMQ_REP
socket each message sent must consist of an empty message part, the delimiter, followed by one or more body parts."