The DEALER to REP Combination
Now, letâs replace the REQ client with a DEALER. This gives us an asynchronous client that can talk to multiple REP servers. If we rewrote our âHello Worldâ client using DEALER, weâd be able to send off any number of âHelloâ requests without waiting for replies.
When we use a DEALER to talk to a REP socket, we must accurately emulate the envelope that the REQ socket would have sent, or the REP socket will discard the message as invalid. So, to send a message, we:
Send an empty message frame with the
MORE
flag set.Send the message body.
And when we receive a message, we:
Receive the first frame and, if itâs not empty, discard the whole message.
Receive the next frame and pass that to the application.
Get ZeroMQ now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.