|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-05-27 12:52 UTC] dietrich dot ayala at foundstone dot com
If I make a persistent connection to a host, then cycle the host, subsequent requests to pfsockopen return a connection (no error), but any subsequent calls to fgets() (and any socket-accessing kin) using the pointer fail w/ bad connection errors. Previously, I reported this problem when the host *never* comes back up, and Wez fixed that. But it appears this also happens when the host is cycled as well. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 18:00:01 2025 UTC |
Repro script is below. i tested w/ w2k+FastCGI and w2k+isapi, and could repro the behaviour w/ both. steps: 1. run the script 2. take host down and back up, or even just cycle the listening app on the specified port. either one will repro the bug. 3. run the script again. if you're using isapi or fastcgi, it'll attempt to reuse the connection, but won't reconnect, and will display the behaviour described. <?php $host = 'd-w2kserv'; $port = 80; // open connection if(!$fp = pfsockopen($host, $port, $errno, $error_str)){ die('error: '.$error_str.$phperrormsg); } else { // write data $requestMsg = "GET / HTTP/1.1\r\nHost: $host\r\n\r\n"; if(!@fwrite($fp, $requestMsg)) { die('error: '.$phperrormsg); } // read data do { // array of connections $read = array($fp); // use stream_select() for non-busy wait if (false === ($num_changed_streams = stream_select($read, $write = NULL, $except = NULL, 0))) { die('Stream_select returned error: '.$phperrormsg); // At least on one of the streams something interesting happened } elseif ($num_changed_streams > 0) { if( !$data = @fgets($fp, 8192) ){ die('couldnt get data from socket, or socket returned no data'); } print $data; // no more data if (feof($fp) || $data === false || strlen($data) == 0) { break; } } } while(true); } ?>