ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
you will transfer some binary code to a server an execute it ? localy ?
why should anyone want this ? use a shared lib or rpc if anything else break.
(actualy you could use a shared lib, see ldopen() )
the client-server model basicly say: take this and send me result. easy to implement easy to debug (e.g. with telnet).
X11 let you redefine some functions noone uses it. why ? because you end in unpleasant places.
Distribution: Slackware & Slamd64. What else is there?
Posts: 1,705
Rep:
An API is the code interface between service consumer and service provider. It sounds like what you're talking about here is the back-end code implementation (of the service provider code) and not an API- and this problem is not specific to APIs. You might get more help if you change the topic (is that possible?) to target your actual question which sounds like a question on how to choose an optimal IPC technique for your situation.
There's no strict need to do conversion to strings or even XML in order to use any IPC. If the objects contain references (i.e. pointers to other objects or block of data), you will need to serialize the entire tree of linked object of course, because it doesn't make sense to pass a literal memory address (pointer). But you can do this all binary without problem, with any IPC method.
Quote:
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.
Did you think of message queue's? If your objects are not too big, a message queue may be a suitable method in your case.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.