Chapter 2. Sockets and Patterns

In Chapter 1 we took ØMQ for a drive, with some basic examples of the main ØMQ patterns: request-reply, publish-subscribe, and pipeline. In this chapter, we’re going to get our hands dirty and start to learn how to use these tools in real programs.

We’ll cover:

  • How to create and work with ØMQ sockets

  • How to send and receive messages on sockets

  • How to build your apps around ØMQ’s asynchronous I/O model

  • How to handle multiple sockets in one thread

  • How to handle fatal and nonfatal errors properly

  • How to handle interrupt signals like Ctrl-C

  • How to shut down a ØMQ application cleanly

  • How to check a ØMQ application for memory leaks

  • How to send and receive multipart messages

  • How to forward messages across networks

  • How to build a simple message queuing broker

  • How to write multithreaded applications with ØMQ

  • How to use ØMQ to signal between threads

  • How to use ØMQ to coordinate a network of nodes

  • How to create and use message envelopes for publish-subscribe

  • How to use the high-water mark (HWM) to protect against memory overflows

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.