Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:22606 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 23555 invoked by uid 1010); 28 Mar 2006 20:59:29 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 23540 invoked from network); 28 Mar 2006 20:59:29 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Mar 2006 20:59:29 -0000 X-Host-Fingerprint: 204.127.200.83 sccrmhc13.comcast.net NetCache Data OnTap 5.x Received: from ([204.127.200.83:63049] helo=sccrmhc13.comcast.net) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id 47/47-14993-0B3A9244 for ; Tue, 28 Mar 2006 15:59:28 -0500 Received: from smailcenter47.comcast.net ([204.127.205.147]) by comcast.net (sccrmhc13) with SMTP id <2006032820592401300edqrpe>; Tue, 28 Mar 2006 20:59:24 +0000 Received: from [67.174.105.139] by smailcenter47.comcast.net; Tue, 28 Mar 2006 20:59:24 +0000 To: internals@lists.php.net Date: Tue, 28 Mar 2006 20:59:24 +0000 Message-ID: <032820062059.19729.4429A3AC0005601D00004D112200762194CEC7CE9D0E9B9C0A9A09019D@comcast.net> X-Mailer: AT&T Message Center Version 1 (Aug 4 2005) X-Authenticated-Sender: cm9ndWVzdGFyMTkxQGNvbWNhc3QubmV0 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="NextPart_Webmail_9m3u9jl4l_19729_1143579564_0" Subject: Re: [PHP-DEV] can Php - Fast-CGI and STDIN be used? From: roguestar191@comcast.net --NextPart_Webmail_9m3u9jl4l_19729_1143579564_0 Content-Type: text/plain Content-Transfer-Encoding: 8bit sorry the word abuse pissed me off. I'm not abusing anything the protocols weren't designed to support (even if they don't know it, but then, they do know it). I can understand if nobody ever thought of this use of it before and is why there is no support for using fcgistdin with php, even tho any other programming language can use it if it properly and _fully_ supports the fast-cgi protocol. The easiest way I can think of to make a fast-cgi client application would be to simple close socket 0, and socket 1 (stdin and stdout), then dup2ing to the end of a pipe, cout data would be grabbed from the end of one of the pipes, wrapped in a fast-cgi header, printed to the server, stdin data from the server would come in to a second thread (or a multiplexing select() core), using the request id it finds the proper stdin pipe and just sends the data there. That's not hard to do, that's not off from the fast-cgi protocol, that's not an abuse, and that would allow the very simple stdin/stdout protocols to work for the easiest, most extendable server scripting ever convieved. -------------- Original message -------------- From: "Wez Furlong" > IMO, you're better off using stream_socket_server() and writing a > "real" daemon for that. Abusing fastcgi/cgi to work in that way is > only going to bite you in the ass. > > --Wez > > On 3/24/06, Matthew wrote: > > 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 > > > > --NextPart_Webmail_9m3u9jl4l_19729_1143579564_0--