<p>I'm looking for suggestions on possible IPC mechanisms that are:</p>

<ul>
<li><strong>Cross platform</strong> (Win32 and Linux at least)</li>
<li>Simple to implement in <strong>C++</strong> as well as the <strong>most common scripting languages</strong> (perl, ruby, python, etc).</li>
<li>Finally, <strong>simple to use</strong> from a programming point of view!</li>
</ul>

<p>What my options are? I'm programming under Linux, but I'd like what I write to be portable to other OSes in the future. I've thought about using sockets, named pipes, or something like DBus.</p>

[{'answer_id': 60660, 'author': 'Brian R. Bondy', 'author_id': 3153, 'author_profile': 'https://Stackoverflow.com/users/3153', 'pm_score': 4, 'selected': False, 'text': '<p>For C++, check out <a href="http://www.boost.org/doc/libs/1_36_0/doc/html/interprocess.html" rel="noreferrer">Boost IPC</a>.<br>\nYou can probably create or find some bindings for the scripting languages as well.  </p>\n\n<p>Otherwise if it\'s really important to be able to interface with scripting languages your best bet is simply to use files, pipes or sockets or even a higher level abstraction like HTTP. </p>\n'}, {'answer_id': 60662, 'author': 'Swaroop C H', 'author_id': 4869, 'author_profile': 'https://Stackoverflow.com/users/4869', 'pm_score': 3, 'selected': False, 'text': '<p>How about <a href="http://incubator.apache.org/thrift/" rel="noreferrer">Facebook\'s Thrift</a>?</p>\n\n<blockquote>\n  <p>Thrift is a software framework for scalable cross-language services development. It combines a software stack with a code generation engine to build services that work efficiently and seamlessly between C++, Java, Python, PHP, Ruby, Erlang, Perl, Haskell, C#, Cocoa, Smalltalk, and OCaml.</p>\n</blockquote>\n'}, {'answer_id': 60668, 'author': 'Maximilian', 'author_id': 1733, 'author_profile': 'https://Stackoverflow.com/users/1733', 'pm_score': 2, 'selected': False, 'text': '<p>It doesn\'t get more simple than using pipes, which are supported on every OS I know of, and can be accessed in pretty much every language.</p>\n\n<p>Check out <a href="http://web.archive.org/web/20080919054639/http://www.utdallas.edu/~kcooper/teaching/3375/Tutorial6a/tutorial6.htm" rel="nofollow noreferrer">this</a> tutorial.</p>\n'}, {'answer_id': 60692, 'author': 'GEOCHET', 'author_id': 5640, 'author_profile': 'https://Stackoverflow.com/users/5640', 'pm_score': 2, 'selected': False, 'text': '<p>TCP sockets to localhost FTW.</p>\n'}, {'answer_id': 60702, 'author': 'Douglas Leeder', 'author_id': 3978, 'author_profile': 'https://Stackoverflow.com/users/3978', 'pm_score': 3, 'selected': False, 'text': "<p>I think you'll want something based on sockets. </p>\n\n<p>If you want RPC rather than just IPC I would suggest something like XML-RPC/SOAP which runs over HTTP, and can be used from any language.</p>\n"}, {'answer_id': 65924, 'author': 'Douglas Mayle', 'author_id': 8458, 'author_profile': 'https://Stackoverflow.com/users/8458', 'pm_score': 7, 'selected': True, 'text': '<p>In terms of speed, the best cross-platform IPC mechanism will be pipes.  That assumes, however, that you want cross-platform IPC on the same machine.  If you want to be able to talk to processes on remote machines, you\'ll want to look at using sockets instead.  Luckily, if you\'re talking about TCP at least, sockets and pipes behave pretty much the same behavior.  While the APIs for setting them up and connecting them are different, they both just act like streams of data.</p>\n\n<p>The difficult part, however, is not the communication channel, but the messages you pass over it.  You really want to look at something that will perform verification and parsing for you.  I recommend looking at Google\'s <a href="http://code.google.com/apis/protocolbuffers/docs/overview.html" rel="noreferrer">Protocol Buffers</a>. You basically create a spec file that describes the object you want to pass between processes, and there is a compiler that generates code in a number of different languages for reading and writing objects that match the spec.  It\'s much easier (and less bug prone) than trying to come up with a messaging protocol and parser yourself.</p>\n'}, {'answer_id': 66069, 'author': 'Jason Etheridge', 'author_id': 2193, 'author_profile': 'https://Stackoverflow.com/users/2193', 'pm_score': 2, 'selected': False, 'text': '<p>If you\'re willing to try something a little different, there\'s the <a href="http://zeroc.com/ice.html" rel="nofollow noreferrer">ICE</a> platform from <a href="http://zeroc.com" rel="nofollow noreferrer">ZeroC</a>. It\'s open source, and is supported on pretty much every OS you can think of, as well as having language support for C++, C#, Java, Ruby, Python and PHP. Finally, it\'s very easy to drive (the language mappings are tailored to fit naturally into each language). It\'s also fast and efficient. There\'s even a cut-down version for devices.</p>\n'}, {'answer_id': 67532, 'author': 'Bronek', 'author_id': 10042, 'author_profile': 'https://Stackoverflow.com/users/10042', 'pm_score': 3, 'selected': False, 'text': '<p>You might want to try <a href="http://www.msobczak.com/prog/yami/" rel="noreferrer" title="YAMI">YAMI</a> , it\'s very simple yet functional, portable and comes with binding to few languages</p>\n'}, {'answer_id': 74590, 'author': 'apenwarr', 'author_id': 42219, 'author_profile': 'https://Stackoverflow.com/users/42219', 'pm_score': 3, 'selected': False, 'text': '<p>Why not D-Bus?  It\'s a very simple message passing system that runs on almost all platforms and is designed for robustness.  It\'s supported by pretty much every scripting language at this point.</p>\n\n<p><a href="http://freedesktop.org/wiki/Software/dbus" rel="noreferrer">http://freedesktop.org/wiki/Software/dbus</a></p>\n'}, {'answer_id': 74615, 'author': 'Adam Rosenfield', 'author_id': 9530, 'author_profile': 'https://Stackoverflow.com/users/9530', 'pm_score': 0, 'selected': False, 'text': '<p>Python has a pretty good IPC library: see <a href="https://docs.python.org/2/library/ipc.html" rel="nofollow noreferrer"><a href="https://docs.python.org/2/library/ipc.html" rel="nofollow noreferrer">https://docs.python.org/2/library/ipc.html</a></a></p>\n'}, {'answer_id': 351256, 'author': 'lothar', 'author_id': 44434, 'author_profile': 'https://Stackoverflow.com/users/44434', 'pm_score': 2, 'selected': False, 'text': '<p>Distributed computing is usually complex and you are well advised to use existing libraries or frameworks instead of reinventing the wheel. Previous poster have already enumerated a couple of these libraries and frameworks. Depending on your needs you can pick either a very low level (like sockets) or high level framework (like CORBA). There can not be a generic "use this" answer. You need to educate yourself about distributed programming and then will find it much easier to pick the right library or framework for the job.</p>\n\n<p>There exists a wildly used C++ framework for distributed computing called ACE and the CORBA ORB TAO (which is buildt upon ACE). There exist very good books about ACE <a href="http://www.cs.wustl.edu/~schmidt/ACE/" rel="nofollow noreferrer">http://www.cs.wustl.edu/~schmidt/ACE/</a> so you might take a look. Take care!</p>\n'}, {'answer_id': 2136606, 'author': 'mloskot', 'author_id': 151641, 'author_profile': 'https://Stackoverflow.com/users/151641', 'pm_score': 3, 'selected': False, 'text': '<p><a href="http://www.msobczak.com/prog/yami/" rel="noreferrer">YAMI - Yet Another Messaging Infrastructure</a> is a lightweight messaging and networking framework.</p>\n'}, {'answer_id': 25034401, 'author': 'Peque', 'author_id': 3577054, 'author_profile': 'https://Stackoverflow.com/users/3577054', 'pm_score': 3, 'selected': False, 'text': '<p>If you want a portable, easy to use, multi-language and <a href="http://zeromq.org/intro:commercial-support" rel="noreferrer">LGPL</a>ed solution, I would recommend you <a href="http://zeromq.org/" rel="noreferrer">ZeroMQ</a>:</p>\n\n<ul>\n<li>Amazingly fast, almost linear scaleable and still simple.</li>\n<li>Suitable for simple and complex systems/architectures.</li>\n<li>Very powerful communication patterns available: REP-REP, PUSH-PULL, PUB-SUB, PAIR-PAIR.</li>\n<li>You can configure the transport protocol to make it more efficient if you are passing messages between threads (<strong><code>inproc://</code></strong>), processes (<strong><code>ipc://</code></strong>) or machines (<strong><code>{tcp|pgm|epgm}://</code></strong>), with a smart option to shave off some part of the protocol overheads in case of connections are running between VMware virtual machines (<strong><code>vmci://</code></strong>).</li>\n</ul>\n\n<p>For serialization I would suggest <a href="http://msgpack.org/index.html" rel="noreferrer">MessagePack</a> or Protocol Buffers (which other have already mentioned as well), depending on your needs.</p>\n'}, {'answer_id': 37910705, 'author': 'Alexander Saprykin', 'author_id': 6459465, 'author_profile': 'https://Stackoverflow.com/users/6459465', 'pm_score': 3, 'selected': False, 'text': '<p>I can suggest you to use the <a href="https://github.com/saprykin/plibsys" rel="noreferrer">plibsys</a> C library. It is very simple, lightweight and cross-platform. Released under the LGPL. It provides:</p>\n\n<ul>\n<li>named system-wide shared memory regions (System V, POSIX and Windows implementations);</li>\n<li>named system-wide semaphores for access synchronization (System V, POSIX and Windows implementations);</li>\n<li>named system-wide shared buffer implementation based on the shared memory and semaphore;</li>\n<li>sockets (TCP, UDP, SCTP) with IPv4 and IPv6 support (UNIX and Windows implementations).</li>\n</ul>\n\n<p>It is easy to use library with quite a good documentation. As it is written in C you can easily make bindings from scripting languages.</p>\n\n<p>If you need to pass large data sets between processes (especially if speed is essential) it is better to use shared memory to pass the data itself and sockets to notify a process that the data is ready. You can make it as following:</p>\n\n<ul>\n<li>a process puts the data into a shared memory segment and sends a notification via a socket to another process; as a notification usually is very small the time overhead is minimal;</li>\n<li>another process receives the notification and reads the data from the shared memory segment; after that it sends a notification that the data was read back to the first process so it can feed more data.</li>\n</ul>\n\n<p>This approach can be implemented in a cross-platform fashion.</p>\n'}, {'answer_id': 52486808, 'author': 'Paul Lefebvre', 'author_id': 25615, 'author_profile': 'https://Stackoverflow.com/users/25615', 'pm_score': 0, 'selected': False, 'text': '<p>Xojo has built-in cross-platform IPC support with its <a href="https://docs.xojo.com/index.php/IPCSocket" rel="nofollow noreferrer">IPCSocket class</a>. Although you obviously couldn\'t "implement" it in other languages, you could use it in a Xojo console app and call it from other languages making this option perhaps very simple for you.</p>\n'}, {'answer_id': 60543455, 'author': 'bloody', 'author_id': 4241078, 'author_profile': 'https://Stackoverflow.com/users/4241078', 'pm_score': 0, 'selected': False, 'text': '<p>In the current ages there is available a very easy, C++1x compliant, well documented, Linux and Windows compatible, open-source "CommonAPI" library: <a href="https://at.projects.genivi.org/wiki/pages/viewpage.action?pageId=5472311" rel="nofollow noreferrer">CommonAPI C++</a>.</p>\n\n<p>The underlying IPC system is D-Bus (libdbus) or SomeIP if one wish. Application interfaces are specified using a simple and tailored for that Franca IDL language.</p>\n'}]
['https://Stackoverflow.com/questions/60649', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1304/']