Book Image

ZeroMQ

By : Faruk Akgul
Book Image

ZeroMQ

By: Faruk Akgul

Overview of this book

<p>ØMQ (also spelled ZeroMQ, 0MQ, or ZMQ) is a high-performance asynchronous messaging library aimed at use in scalable distributed or concurrent applications. It provides a message queue, but unlike message-oriented middleware, a ØMQ system can run without a dedicated message broker. The library is designed to have a familiar socket-style API.<br /><br />"ZeroMQ" teaches you to use ZeroMQ through examples in C programming language. You will learn how to use fundamental patterns of message/queuing with a step-by-step tutorial approach and how to apply them. Then, you’ll learn how to use high level APIs and to work with multiple sockets and multithreaded programs through many examples.<br /><br />This book looks at how message/queue works in general and what kinds of problems it solves. Then, it explains how ZeroMQ works and how it differs from other message/queue libraries and how it can be used in different scenarios.<br /><br />You will also learn how to apply essential message/queue design patterns in different scenarios, and how they differ from each other. It shows you practical examples you can apply. You will also learn how to work with multiple sockets.<br /><br />You will learn the basics of ZeroMQ as well as how to use different patterns.</p>
Table of Contents (12 chapters)

Types of Internet sockets


There are different types of Internet sockets. You may have seen SOCK_DGRAM, SOCK_STREAM, and SOCK_RAW before. The following are the brief definitions of the most popular ones:

  • Stream sockets (SOCK_STREAM): These types of sockets use Transmission Control Protocol (TCP) or Stream Control Transmission Protocol (SCTP). It ensures that sent data is sequenced and unduplicated and it is a reliable socket. A sample usage would be socket(PF_INET, SOCK_STREAM, 0);.

  • Datagram sockets (SOCK_DGRAM): These types of sockets use User Datagram Protocol (UDP). These sockets are known as connectionless sockets. It should be noted that they are unreliable and the data may arrive out of sequence. There may be duplication as well. A sample usage would be socket(PF_INET, SOCK_DGRAM, 0);.

  • Raw sockets (SOCK_RAW): These types of socket neither use TCP nor UDP. It directly communicates with the IP layer. This may be useful to build a new protocol and is a lower-level approach.

    The network...