I'm sorry if this is the wrong place for this post, I just don't know where
else to go. 

I need some help figuring out how to use FCGI_STDIN with a running php
script.

I have written a server in c++, which for a while been running php through
it's plain old cgi interface. I have been using php for 2 things, the
obvious one, web pages, and the not so obvious, safe command/server
scripting. I have just implimented a fast-cgi interface to replace the cgi
interface, however, the scripting stuff i had that worked over regular cgi
just doesn't want to work with fast-cgi.

Basically, the php script outputs a command and arguments, all commands
start with a %, so:
$var = "%print";
printf("%s hello world\n", $var); 
Can be used to print to the user calling the script.

That part still works fine of course :).

It doesn't stop there however, some of the %callbacks will return strings of
data over stdin so they can be $var = trim(fgets($STDIN)) for a very simple
and effective method of communicating with the server.

I've tried doing the same with fast-cgi, but it seems
fopen("php://stdin","r") is not the right place to be reading from.

I'm sending:

(C++)
// loops over ever line of input, test it
std::string response = processALineFromCGI-OrFastCGIScript(oneLine)
if(response.compare("NOCMD") == 0)
buffer_to_print_to_user_who_called_this_when_request_finishs();
else if(response.size() > 0) {
 std::string sendout = FCGI_Headerize(response, FCGI_STDIN, ..);
 non-blocking_send(sendout);
}
oneLine.erase();
I use the same function to build the headers for FCGI_BEGIN_REQUEST,
FCGI_PARAMS, FCGI_STDIN on POST input, it works great there(now)


Also, is it possible to keep the connection open to php-cgi to avoid
connect/accept calls? Even if it's only fifo so only 1 request can go at a
time?

If I must I could create a special c++ fast-cgi server that binds a second
port to pipe requests from php streams to the server, but would be a MAJOR
hack for what I'm trying to do.. :-D

Thanks in advance!

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to