ZeroMQ sockets

ZeroMQ sockets have four different methods, just like normal sockets, as we have said at the beginning of this chapter. It should be noted that ZeroMQ sockets are always void pointers and are asynchronous.

Differences between TCP sockets and ZeroMQ sockets

The following is the difference between TCP sockets and ZeroMQ sockets:

  • ZeroMQ sockets are asynchronous.
  • They may implement particular patterns.
  • TCP sockets are one-to-one whereas ZeroMQ sockets are many-to-many. However, you could implement one-to-many, one-to-one, many-to-one, or many-to-many with ZeroMQ, depending on your needs and socket type.
  • ZeroMQ sockets transmit messages whereas TCP transmit bytes. As we said in Chapter 1, Getting Started, a message is a fixed-length binary object.
  • I/O is done in the background in ZeroMQ sockets. Even if your application is too busy to handle messages, they are put in queues.
  • Unlike TCP, ZeroMQ sockets do not care whether the destination exists or not.
  • ZeroMQ sockets may transmit data to multiple nodes and receive data from multiple nodes.

We cannot start the source node and then the destination node when we work with TCP sockets. This is because the source node would immediately try to connect to the destination and if there was no destination present to receive the message, then we would have a problem. However, in ZeroMQ, the message can be enqueued and sent later if there is no destination to receive the message. Another difference is that we tell ZeroMQ to send and receive messages instead of bytes.

Differences between TCP sockets and ZeroMQ sockets

ZeroMQ sockets are many-to-many

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.42.168