The Socket API
To be perfectly honest, ÃMQ does a kind of switch-and-bait on you, for which we donât apologize. Itâs for your own good, and it hurts us more than it hurts you. It presents a familiar socket-based API, which requires great effort for us to hide a bunch of message-processing engines. However, the result will slowly fix your world view about how to design and write distributed software.
Sockets are the de facto standard API for network programming, as well as being useful for stopping your eyes from falling onto your cheeks. One thing that makes ÃMQ especially tasty to developers is that it uses sockets and messages instead of some other arbitrary set of concepts. Kudos to Martin Sustrik for pulling this off. It turns âMessage Oriented Middleware,â a phrase guaranteed to send the whole room off to Catatonia, into âExtra Spicy Sockets!,â which leaves us with a strange craving for pizza and a desire to know more.
Like a favorite dish, ÃMQ sockets are easy to digest. These sockets have a life in four parts, just like BSD sockets:
We can create and destroy them, which go together to form a karmic circle of socket life (see
zmq_socket()
,zmq_close()
).We can configure them by setting options on them and checking them if necessary (see
zmq_setsockopt()
,zmq_getsockopt()
).We can plug them into the network topology by creating ÃMQ connections to and from them (see
zmq_bind()
,zmq_connect()
).We can use them to carry data by writing and receiving messages on them ...
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.