4

So as I have asked in a previous post, I want to be able to make programs or functions written in different languages to communicate between them.

I have come across zeromq recently and I'm trying to figure out whether or not this is something that could help me since it provides some sort of sockets. Can zeromq for example exchange data (or pass arguments) between a program written in python with a program or a function written in C++ or is its function for something completely different?

Jethro
  • 475
  • 2
  • 5
  • 12

2 Answers2

1

ZeroMQ is an abstraction of sockets. It is cross platform and have lots of language binding: I personally don't know any language that doesn't have ZeroMQ bindings.

So yes, you can use ZeroMQ to communicate between a program written in Python and program written in C++.

I recommend going through the zguide as it contains a lot of very useful information about ZeroMQ.

PyZMQ can be used as Python binding, and zmqpp for your C++ code. Note that for the C++ code you could also use cppzmq or the zmq C API directly. I would recommend using zmqpp as its higher level and (imho) easier to use.

Xaqq
  • 4,308
  • 2
  • 25
  • 38
1

A: Oh Yes, exactly that is the power of ZeroMQ or nanomsg frameworks

Both of these are not sockets but rather BEHAVIOUR created within a context of a Zero-* -- a set of courageous maxims the Scaleable Formal Communication Pattern Framework was designed, developed and finetuned to meet.

That will enable you to assemble your own fast & smart messaging layer(s).

Q: What is the best next step?

In spite of your first impression, simly do forget anything you know about sockets and multithreaded synchronisation tricks.

Yes, rather forget and build your new understanding on "green field".

Take Pieter HINTJENS' book "Code Connected, Volume 1" (accessible in PDF ) and spend a few weeks on understanding both the motivation and the typical errors Pieter has hammered into this must-read bible of ZeroMQ.

Code-snippets are dangerous in case you did not get or completely missed the full-context of the bigger picture.

Believe me. I could not give you better advice. You may check my other posts on ZeroMQ & nanomsg, to see the difference.

You will definitely benefit from this book and ZeroMQ will give you many powers you would never ( and believe me never ) would be ready to program from scratch on your own. The power is so immense ( if well re-used ).


nota bene

For real-world inter-process communications, there is one minor issue to be aware of. Various ZeroMQ versions' inter-operability. Yes, the power of ZeroMQ is immense, nevertheless, it is necessary to keep the version control built in your messaging layer so as to solve situations, where some platforms do not have an update-path to "newer" releases available. Went into this issue with re-integration of a trading system with a component, where as old as zmq.__version__ == 2.1.11 was necessary, while recent are versions well above 14.x.y, so as to be assured to be 100% end-to-end backward-compatible.

Still, the overall potential is so immense, it makes sense to persevere and get the job done. G/L on that.

user3666197
  • 1
  • 6
  • 50
  • 92
  • The libzmq development trunk is version `4.2`. We are not anywhere near `14.x.y` -- yet :) – Xaqq Jun 02 '15 at 22:45
  • 1
    Thanks a lot for your answer which is extremely helpful and appreciated! I do not know a lot about sockets so it won't be difficult to " forget anything you know about sockets". I was just trying to find a way to make different programs communicate and I have come across this. I do not know what nanomg is to be honest but I will have a look into that as well and I have already started reading the Code Connected book. Once again thanks a lot :) – Jethro Jun 03 '15 at 09:43
  • Enjoy the book start-to-end. Indeed a great piece of a life-journey story from Pieter... G/L Jethro on that way ahead. Worth both following the state-of-art practice and avoid mistakes Pieter has genuinely included so as to recognise them and avoid repeating 'em ( if possible ) :o) – user3666197 Jun 03 '15 at 10:30
  • @Xaqq FYI: **`print zmq.__version__`** >>> **`14.6.0`** – user3666197 Jun 03 '15 at 23:15
  • Well, I have no idea what this `zmq.__version__` is then, but it certainly isn't the libzmq version. – Xaqq Jun 04 '15 at 08:43