Web Page front end with C computation in the Back end
Hi I have a couple of C programs which are accept a certain input and make some complex computations to calculate the output.
Now my aim is to make the C programs as a background process which is called by web-UI by supplying the input and retrieving the output a开发者_如何学Cnd displaying it in the web-UI.
How may I bind my C programs with a Web oriented language like php for instance.
Thanks in advance.
You can invoke a system call with back-tick operators such as:
$ouput = `yourprogram arg1 arg2`;
Please note, you must must must sanitize your input if you are expecting to pass user data into this command.
However, since you've stated you wish to run this in the background, I suggest checking out a message queueing system such as Gearman, which has C libraries(for both workers and clients) which would help in hooking into your C application. Gearman also has plenty of libraries for web languages such as PHP. Gearman supports both synchronous and asynchronous(aka background) tasks.
精彩评论