#23837 [NoF->Csd]: pfsockopen() returning bad connection when host restarts

From: Date: Thu, 18 Sep 2003 17:29:02 +0000
Subject: #23837 [NoF->Csd]: pfsockopen() returning bad connection when host restarts
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-47788@lists.php.net to get a copy of this message
 ID:               23837
 Updated by:       iliaa@php.net
 Reported By:      dietrich dot ayala at foundstone dot com
-Status:           No Feedback
+Status:           Closed
 Bug Type:         Sockets related
 Operating System: windows 2000
 PHP Version:      4.3.2RC4
 Assigned To:      wez
 New Comment:

This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.

User reports that the problem was in fact fixed in the CVS.


Previous Comments:
------------------------------------------------------------------------

[2003-09-18 06:04:08] sniper@php.net

No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.



------------------------------------------------------------------------

[2003-09-11 01:08:53] iliaa@php.net

Please try using this CVS snapshot:

  http://snaps.php.net/php4-STABLE-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-STABLE-latest.zip



------------------------------------------------------------------------

[2003-05-27 17:40:23] dietrich dot ayala at foundstone dot com

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);
}
?>

------------------------------------------------------------------------

[2003-05-27 17:16:27] sniper@php.net

No example script here either. Can not reproduce.


------------------------------------------------------------------------

[2003-05-27 14:47:45] wez@php.net

Assigning to myself; it would be good if some other people could verify
if this problem exists on other platforms, and if this is a critical
issue.


------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/23837

-- 
Edit this bug report at http://bugs.php.net/?id=23837&edit=1


Thread (7 messages)

« previous php.bugs (#47788) next »