Hello,
I've been working on a C JSON-RPC Library. It is designed for embedded
environments / Linux. The goal is to provide JSON-RPC encoding/
decoding with optional encryption, full-duplex peer-to-peer
communication (i.e. ability to send & receive requests and responses),
a multi-threaded TCP/IP socket transport layer, ability to support
multiple connections, ability to simultaneously establish outgoing
connections while listening for incoming connections, automatic
connection re-establishment for dropped connections, support for
receiving requests and dispatching responses with a server RPC method
registry, and a JSON-RPC compiler that auto-generates the C code for
all the important implementations.
The application that this is designed for is an embedded device
running on a linux router/gateway that would sit behind a firewall in
a home residence that communicates with a central server as well as
several GUI clients on the local network.
The JSON-RPC compiler likely requires additional explanation: You will
notice that in many implementations, a great deal of code is required
to marshal and de-marshal parameters on both client side and the
server side. The JSON-RPC compiler reads an "IDL" file which is a
description of the JSON-RPC services a server offers and creates the
following files:
1. clientStubs.c/h (containing code a client would call to invoke the
RPC)
2. serverSkeletons.c/h (containing code run by the server to de-
marshall params, call the server implementation of the RPC, and
marshall the return value)
3. serverImpls.c/h (containing stub code that the application writer
would complete to implement an RPC function).
The "IDL file" is encoded in JSON itself and could also be used as an
extension to a JSON-RPC service to self-describe the methods it offers
like a *.wdsl in web services. After the dust settles on the JSON-RPC
2.0 discussion, I was intending to submit the spec for this as an
extension (previous discussion threads pointed to some interest in
having a service self-description language).
If you are familiar with CORBA or similar, this is essentially an ORB
written for JSON-RPC - encoding, transport, error-recovery, service
registration, IDL compilation. It depends on no other libraries other
than std C libraries and pthreads. It does not require a browser as it
is socket based.
The functionality was designed so that as a user, you can design an
IDL, compile it to standard C structures and function calls, and call
these as if they were local functions. The setup is minimal -
typically, a client calls an RPC_OpenEnv() call with cfg info and
hRPCConn = RPC_OpenConn(sock_addr_in) to open a connection to start
things off. After that, client calls are made by calling the client
stub that was already created for you by the JSON-RPC compiler. An
example call would be:
char *szRetValue;
struct TComplexParam complexParam = {...};
double numParam = ...;
char *szStrParam = "...";
if (exampleRPC(hRPCConn, numParam, szStrParam, &complexParam,
&szRetValue) != RPCSuccess)
{
// Handle error
}
Notice the only thing that alludes to the call being an RPC call is
the inclusion of the first param hRPCConn. No other RPC-specific
structures required.
Yikes - sorry for the long post.
In any case, I have full functionality written and "unit-tested". It
is going into a commercial product later this year, but will likely be
available under some open source license (BSD, GPL, others? I have to
figure out which is best). If you are interested in looking at it and
possibly helping out extended the library, let me know. Lots of
possible extensions: HTTP transport, additional encryption methods,
implementations in other languages (such as Java!), better packaging
for Linux deployment (I'm normally a Microsoft guy - gasp! - so Linux
packages/makefiles are new to me).
I will be duplicating most of this functionality in an OOP format for
ActionScript (Adobe's Flex Builder 3 environment) for use in RIA Adobe
AIR/Flex applications and for Microsoft C# .NET 3.5 for our "central
server" implementation.
Best,
George
P.S. I would like to credit MJSON (
http://mjson.sourceforge.net/
index.html) for the low-level JSON encoding/decoding.
On Jun 7, 2:37 pm, maverick <
maverick...@gmail.com> wrote:
> Hi,
> I would like to use JSON-RPC for a client server communication. We
> are planing to implement server in java and client in C. I could find
> some libraries for this in Java. But in C, only this onehttp://
www.big-llc.com/software.jsp. Is there any other C libraries
> available ?
>
> regards,
> maverick