Thread: Creating APIs
View Single Post
Old 06-14-2006, 02:22 PM   #1 (permalink)
blackhock
Registered User
 
Join Date: Jun 2006
Posts: 1
blackhock is on a distinguished road
Creating APIs

Hi,

We are developing an application for which we want to create an API. The API should allow client applications to call functions in a daemon process. A simple scenario: A client would call a function in the API binding and pass it some objects, these objects and some control information would be transferred to the daemon process, which would then execute the appropriate function passing it the objects it received.

Note: This client-server model is local, and development is in C++.

We evaluated all the IPC methods for moving data between the client application and the daemon, and in each of them, found that they lack some features in another and impose restrictions not found in others. And thus, to achieve the scenario above, we would have to hack our way and use several IPC mechanisms together to achieve the desired behaviour.

For example, with Unix Domain Sockets, we would have to convert each object from and to a string representation, which sounds like too much overhead. Shared Memory would impose many problems, specifically in releasing the memory, and with dynamically expanding objects, and similarly, FIFOs and Pipes have their share of problems.

Now the question is, how do APIs are generally designed? We looked at D-BUS, but it doesn't have a (usable) C++ binding. Are there other libraries available? Is it really the only way to mix several IPCs together, aren't there any "prettier" ways?

So, to put it in another way, we are not looking for just any way to implement an API, we're looking for an efficient way. We can come up easily with straightforward, inefficient methods, like converting the objects to string or XML and passing them around, but we would rather use a library that is commonly used, and tested.

Thanks in advance.
blackhock is offline   Reply With Quote