Request-Reply Combinations
We have four request-reply sockets, each with a certain behavior. Weâve seen how they connect in simple and extended request-reply patterns. But these sockets are building blocks that you can use to solve many problems.
These are the legal combinations:
REQ to REP
DEALER to REP
REQ to ROUTER
DEALER to ROUTER
DEALER to DEALER
ROUTER to ROUTER
And these combinations are invalid (Iâll explain why):
REQ to REQ
REQ to DEALER
REP to REP
REP to ROUTER
Here are some tips for remembering the semantics. DEALER is like an asynchronous REQ socket, and ROUTER is like an asynchronous REP socket. Where we use a REQ socket, we can use a DEALER; we just have to read and write the envelope ourselves. Where we use a REP socket, we can stick a ROUTER; we just need to manage the identities ourselves.
Think of REQ and DEALER sockets as âclientsâ and REP and ROUTER sockets as âservers.â Mostly, youâll want to bind REP and ROUTER sockets, and connect REQ and DEALER sockets to them. Itâs not always going to be this simple, but it is a clean and memorable place to start.
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.