Forum Moderators: coopster

Message Too Old, No Replies

PHP to C Stdin

         

Glacai

1:29 am on Jul 2, 2003 (gmt 0)

10+ Year Member



Hi,

I'm using php's system() to execute and pass a string to a c program, which produces the complete output. Everything works perfect expect I want the program to be already running to save starting and initialising each time. Maybe direct the post variable to the programs stdin and then stdout to the browser, much like system already does.

Any ideas what I should be looking at? hasn't got to be php.

Thanks.

jatar_k

3:37 pm on Jul 2, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



If I understand the question correctly and you need to use a scripting language to pass to the C prog thn it will ahve to fire up everytime and I don't think can already be running. I assume you mean like some type of daemon.

Though I am not 100% sure I got the gist of your question.

Glacai

4:37 pm on Jul 2, 2003 (gmt 0)

10+ Year Member



Thanks jatar_k,

I've been writing a search engine, only for fun and what I will learn in the process, I've done a few games before and thought this would make a change. I'm not using a standard database, mysql etc., the programs involved create and manipulate my own. At the moment the searcher is called using php system() which is fine but as I add more features etc. this is going to slow down, so I'm just preparing for the future. Basically I want the search string sent to an already running programs stdin and its stdout to the browser, well I think thats what I want to do?! maybe I'll have to go a more complicated route :)

dingman

5:27 pm on Jul 2, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



One way to go about this might be to create a named pipe (man mkfifo) or two to communicate through. If you're not using a threaded server, one approach might be to create a /var/$C-script-name/input pipe for the request from scripts to go to, have the script pass its PID as part of the request going through the pipe, and have the C script write back out to a fifo in /var/$C-script-name/output/$PID. With a threaded server, you might have to add a TID to the fifo name.

No idea if fifo's exist in Windows land. This is also just what I'm coming up with off-the-cuff, so it may have some problems.