ipc over tcp/ip implementation

Posted on 2007-10-14
Medium Priority
Last Modified: 2008-01-09
Hello experts.
I am looking for an open source/bsd licence solution for generic ipc over tcp/ip network.
the basic need are to exchange data between different parts of an distributed app.
I am using c / c++ windows sockets.
Question by:Iys
  • 3
  • 2
  • 2
  • +2
LVL 12

Accepted Solution

OnegaZhang earned 1000 total points
ID: 20074024
At least there are 3 ways based on TCP/IP: CORBA, webservice, and plain socket. Here are some open source libraries that have friendly license.

Open source CORBA solution:  ACE/TAO  http://www.cs.wustl.edu/~schmidt/TAO.html

Open source webservice solution: Axis2/C   http://ws.apache.org/axis2/c/

Plain socket: boost.asio  http://asio.sourceforge.net/

To select the right one, you have to made the following tradeoff:
CORBA is heavier and faster than Webservice;
socket is lighter but requires more work, and complicated interface.
Webservice is lighter than CORBA, but a little bit slower since it is over HTTP and inefficient when transferring binary data and array.
LVL 86

Expert Comment

ID: 20074112
What exactly are you trying to communicate between the processes?

Author Comment

ID: 20074354
I want to communicate serialization of  C  structs and/or XML (with binary data encapsulated)
Webservices are too bloat for me.
I started to implement plain sockets on my own but thought that there may be an open source alternative.
asio sounds close.

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 86

Expert Comment

ID: 20074512
For sending plain XML data, sockets IMO are the best solution - no protocol overhead, since the data is structured in itself. Check out http://msdn2.microsoft.com/en-us/library/ms737889.aspx ("Complete Server and Client Code"), this is all you need to transfer XML data.

Regarding structs: That seems to be a perfect tasks for RPC, since you can use the struct definitions in IDL, thus enabing the MIDL compiler to generate all necessary marshalling code. Start reading at http://msdn2.microsoft.com/en-us/library/aa378651.aspx ("Remote Procedure Call") where you will also find a link to samples and see also the tutorial at http://www.codeproject.com/internet/rpcintro1.asp ("Introduction to RPC - Part 1")
LVL 39

Assisted Solution

itsmeandnobodyelse earned 1000 total points
ID: 20078007
>>>> since you can use the struct definitions in IDL,
>>>> thus enabing the MIDL compiler to generate all
>>>> necessary marshalling code.

If Webservices are too 'bloat' for you, I would recomment against using MIDL. IMO, it is that kind of interfaces which is making more problems than helping especially for use in C++ where the docs are poor and help is hard to get. Let alone that it is as proprietary as any piece of software can be at all.

Using plain sockets is indeed the most easiest way for passing structs. If different platforms are involved you need to care for alignment and endian. But even that can be done in a very transparent and straight forward approach, e. g. by converting each integer member via htonl to network order and back by ntohl when reading the members.

Regards, Alex


Author Comment

ID: 20084872
Do you know of any libraries which implement ipc over plain sockets ?.
LVL 39

Expert Comment

ID: 20084963
>>>> Do you know of any libraries which implement ipc over plain sockets ?
I've written my own libraries. But you may look at the following thread where someone asked the same question:

LVL 11

Expert Comment

ID: 20090505
I've always found that recovery from disconnection is a major problem with most of these packages.  Remove the ethernet cable and everything just freezes or falls over.  Plug it back in and the whole system comes back to life or falls over.

Whatever package you use, make sure you can recover from disconnections and reconnections.  It is always one of the last things to be tested (some project managers even remove it from the test spec).  I have yet to find a solution that is neat and simple.  It gives the customers a lot of confidence when code can recover from disconnections.

With Windows, unless it is a server, if the network cable is removed, it loses its IP address and everything just hangs, even when you have a recovery strategy.  You need to disable media sensing http://support.microsoft.com/kb/239924 to avoid that.

I don't really know if Unix or other OSs have the same problem.
LVL 39

Expert Comment

ID: 20091225
>>>> always found that recovery from disconnection
>>>> is a major problem with most of these packages.
It must not be. If checking with select before any read/accept a disconnection can be detected without timeouts. Same happens if setting the socket to non-blocking. I never had problems with that. But I've seen a lot of implementations which did not handle disconnection but only have error handling which makes a retry. Such a system rarely will recover in case of a disconnection.

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
Creating an OSPF network that automatically (dynamically) reroutes network traffic over other connections to prevent network downtime.
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question