I like to know how to write a program which would export some API function.
For ex: Suppose I have few function, lets take add(int x,int y), mul(int x,int y) sub(int x, int y).
How can I write a daemon in c such that this will export above API to external world.
And how can I access these APIs from other program?
I am expecting from code point of view… Thanks in advance…
It depends on what you mean by API.
Creating a library
Create a header file. This will be the "interface" of your API. Programs that want to use your library will have to include it in order to do so.
Then you can go on and implement your library in your favorite system-specific way.
Creating a program that services requests
In this case, indeed you want a daemon and probably want to use
RPC. Using this scheme, external programs can call your functions via the network.