A DDP server in C

We are developing a DDP server in the C language (don't ask why - we just need to). We've noticed that Meteor uses SockJS for its DDP protocol implementation. While there are libraries that allow me to do web sockets in C, I haven't found any SockJS libraries for C.

The SockJS library seems to be quite expansive and since there isn't a specification for how it operates, it sounds like a very brittle approach to try to reverse engineer its tricks.

It has left me wondering what the best strategies are for getting us to support DDP. There are few options I can think of:

  1. I could import the V8 engine and use it to bridge between C++ and a JavaScript implementation (which I then could expose to C relatively easily)
  2. I could use SockJS library X for language Y and use Python/C / JNI / ... to interface with that
  3. Perhaps I could force Meteor to use web sockets only (the DDP docs seem to suggest this is possible, but I couldn't figure out how).

Option 3, if at all possible, would be the least effort, but would inherit the issues with WebSockets (browser interoperability, corporate firewalls etc.).

Option 1 and 2 are feasible, but the size of the library I'd have to include feels disproportionate to the functionality I would be using.

Considering the above, there doesn't seem to be a perfect solution. However I would like to validate the feasibility of the above options, and know whether I've missed something. Also, if someone tried this before, I'd love to hear about it.


I implemented an open source DDP server library in C++, that handles the protocol details. It should be used with some existing websocket library, such as mongoose, websocketpp, libwebsockets, etc.

So e.g. calling C++ methods from a MeteorJs site looks like this:

Getting live data from C++ also supported.

More information and examples - on GitHub:

We eventually decided to implement a subset of the SockJS protocol (http://sockjs.github.io/sockjs-protocol/sockjs-protocol-0.3.3.html) in C, using the Mongoose HTTP sserver (http://www.github.com/cesanta/mongoose).

The part of SockJS that negotiates with the server to verify whether web sockets are available is easy to implement. Additionally, the SockJS protocol wraps the web socket packages in its own header, and does liveliness checking with regular heartbeats.

Negotiation is done by responding to a sockjs/info request. The following response ensures that SockJS uses the web socket protocol:


The screenshot below shows the web socket traffic implemented so far with our SockJsServer & DDPServer:

Need Your Help

Symfony2 - Execution order of test cases

symfony netbeans-7 functional-testing automated-tests

I'm using Symfony Functional Tests in NETBEANS. Is it possible to define the order in which order will the test cases be executed?

PhoneGap with Asp.net MVC 4? - Anyone know what Steve Sanderson was getting at?

asp.net-mvc mobile cordova razor

I watched Single Page Application Presentation and in the 4:15 mark of the video he mentions deploying his single page application to an "app store" by using phonegap.