Want to use your own C libraries in a web application, what are my options?

I have many obsolete C libraries used for numerical analysis and scientific calculations (e.g. simulation) that I want to use in the web application that I am creating (so far I have used Javascript to create the user interface). What options do I have on the client side and / or on the server side? I heard about using my own client with chrome, but I don’t like that the client has to enable the flag of its own client in order to do this.

+4
source share
6 answers

On the server side :

Starting with CGI (Common Gateway Interface) is the most basic method that allows you to use your own C libraries in a web application - in which you delegate an executable file (for example, written in C) to create web content on the server side.

But CGI is very primitive and inefficient. Each command can create a new Process on the server. So there are other viable alternatives here:

  • Apache modules allow you to run third-party software inside the web server itself.
  • FastCGI - Single Process handles multiple user requests.
  • SCGI - Simple CGI

Contact: http://en.wikipedia.org/wiki/Common_Gateway_Interface#Alternatives

On Client side :

Good news and bad news:

You can use PNaCl (Portable Native Client) in chrome. It will be enabled by default.
BUT the first public release is expected at the end of 2013. Search for PNaCl

+3
source

You cannot do much on the client side — you cannot expect the client to have these libraries, and there is no safe way to download and run them.

The easiest way is to write your server side in any way and access them through the web interface. Many languages ​​commonly used for server-side scripting can access native C libraries, or you can even write regular C applications and run them as script agents.

In the "truly exotic" category, you can run what starts with C code in the client if you insert it into a fairly secure environment. For example, see a description of how sqlite (a C database application) was turned into a 100% pure Java application embedding a mips simulator written in java.

http://blog.benad.me/2008/1/22/nestedvm-compile-almost-anything-to-java.html

+1
source

Wt you looked at Wt ? This is pretty neat.

Also you have options for code in cgi (ugly).

Although not C, it is written in C ++. If you can ignore this part: Wt on your service

0
source

You can use Emscripten for this on the client side. However, this is likely to require some refactoring of your existing code to meet the requirements of the asynchronous main JavaScript loop.

Please note that Emscripten is not a proof of concept or anything like that. It is very powerful and is already used to transfer complex code to the Internet. You can watch the demos (listed in the URL above) to find out what you can do with it.

0
source

It looks like you're best off imagining your deprecated C library methods as a server-side (WEB) service. The raw CGI application seems pretty low for this approach, but overall it is correct. C / C ++ libraries are available for creating webservice servers, as well as client-side libraries that support access to the web service and data presentation. For the server side, you can use gSoap , for example.

0
source

Another option would be to use a web server of your choice to transfer regular files and use a custom web server (which should not support the full HTTP specification) connected to your C code to communicate with client-side Javascript.

The two minimal web servers you can use as a base are libuv-webserver and nweb .

0
source

Source: https://habr.com/ru/post/1440852/


All Articles