Search code examples
javascriptcclient-serverclient-sideserver-side

calling C functions in javascript


I'm using javascript to run a server. I want to call c function on the server side. How can I call it? I googled, most of the time there is info on how to use AJAX and .net to call the function. The c function is alread build and saved in some location on the PC. I wanted to call this C function from the javascript on the server side

Anyone has any info regardin this? many many thanks. Regards Vish


Solution

  • You could spawn a child process using the node child_process module.

    var spawn = require('child_process').spawn;
    
    var ls = spawn("ls", ["-l", "-a"], {stdio: "inherit"});
    
    ls.on("exit", function(status) {
        console.log("Done");
    });
    

    See: http://nodejs.org/api/child_process.html