php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70348 stream_select fails
Submitted: 2015-08-24 22:05 UTC Modified: 2015-09-09 04:14 UTC
From: mwilmes at avc dot edu Assigned:
Status: Closed Package: Streams related
PHP Version: 5.6.12 OS: Win 8.1 x64
Private report: No CVE-ID: None
 [2015-08-24 22:05 UTC] mwilmes at avc dot edu
Description:
------------
Using stream_select on Windows generates a warning:
Warning: stream_select(): unable to select [2]: No such file or directory (max_fd=1168) in C:\path\x.php on line 8
Should not create an error. Note that fd changes per iteration.  Error exists using both CLI and Apache php5apache2_4.dll.

Test script:
---------------
<?php
$timeout = 15;

$socket = fsockopen("www.google.com",80,$errno,$errstr,$timeout);
fwrite($socket, "GET / HTTP/1.0\r\n\r\n");
echo fgets($socket);
fclose($socket);

echo "<br>";

$socket = fsockopen("www.google.com",80,$errno,$errstr,$timeout);
$sock_r = null;
$sock_w = array($socket);
$sock_e = null;
$result = stream_select($sock_r,$sock_w,$sock_e,$timeout);
if ($result !== false) {
	fwrite($socket, "GET / HTTP/1.0\r\n\r\n");
	echo fgets($socket);
}
fclose($socket);
?>

Expected result:
----------------
HTTP/1.0 200 OK
<br>
HTTP/1.0 200 OK



Actual result:
--------------
HTTP/1.0 200 OK 

Warning: stream_select(): unable to select [2]: No such file or directory (max_fd=1352) in C:\path\x.php on line 15

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-08-26 16:16 UTC] ab@php.net
-Status: Open +Status: Feedback
 [2015-08-26 16:16 UTC] ab@php.net
Hi,

I don't reproduce this. Probably need a more reliable reproduce case, or you should check your environment. In the PHP code, checking that the returned socket is valid before select should be done, too.

Thanks.
 [2015-09-06 04:22 UTC] php-bugs at lists dot php dot 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 "Re-Opened". Thank you.
 [2015-09-08 17:09 UTC] mwilmes at avc dot edu
-Status: No Feedback +Status: Closed
 [2015-09-08 17:09 UTC] mwilmes at avc dot edu
Updated test script:
<?php
$timeout = 15;

$socket = fsockopen("www.google.com",80,$errno,$errstr,$timeout);
var_dump($socket);
if(!$socket) { 
	echo "Error: bad socket\n"; 
}
else {
	fwrite($socket, "GET / HTTP/1.0\r\n\r\n");
	echo fgets($socket);
	fclose($socket);
}

echo "<br>\n";

$socket = fsockopen("www.google.com",80,$errno,$errstr,$timeout);
var_dump($socket);
if(!$socket) { 
	echo "Error: bad socket\n"; 
}
else {
	$sock_r = null;
	$sock_w = array($socket);
	$sock_e = null;
	$result = stream_select($sock_r,$sock_w,$sock_e,$timeout);
	var_dump($result);
	fwrite($socket, "GET / HTTP/1.0\r\n\r\n");
	echo fgets($socket);	
	fclose($socket);
}

-----

Current output:
C:\php>php bug.php
resource(4) of type (stream)
HTTP/1.0 200 OK
<br>
resource(5) of type (stream)

Warning: stream_select(): unable to select [2]: No such file or directory (max_f
d=300) in C:\php\bug.php on line 26
bool(false)
HTTP/1.0 200 OK

-----

PHP version:
C:\php>php -v
PHP 5.6.12 (cli) (built: Aug  6 2015 12:05:19)

I uninstalled the Security Suite software to ensure it was not related to that.  Still have the same issue.

If this is an environment issue, what things should I be looking for?

I will also take a copy of this home and test it there.
 [2015-09-08 17:10 UTC] mwilmes at avc dot edu
Updated test script:
<?php
$timeout = 15;

$socket = fsockopen("www.google.com",80,$errno,$errstr,$timeout);
var_dump($socket);
if(!$socket) { 
	echo "Error: bad socket\n"; 
}
else {
	fwrite($socket, "GET / HTTP/1.0\r\n\r\n");
	echo fgets($socket);
	fclose($socket);
}

echo "<br>\n";

$socket = fsockopen("www.google.com",80,$errno,$errstr,$timeout);
var_dump($socket);
if(!$socket) { 
	echo "Error: bad socket\n"; 
}
else {
	$sock_r = null;
	$sock_w = array($socket);
	$sock_e = null;
	$result = stream_select($sock_r,$sock_w,$sock_e,$timeout);
	var_dump($result);
	fwrite($socket, "GET / HTTP/1.0\r\n\r\n");
	echo fgets($socket);	
	fclose($socket);
}

-----

Current output:
C:\php>php bug.php
resource(4) of type (stream)
HTTP/1.0 200 OK
<br>
resource(5) of type (stream)

Warning: stream_select(): unable to select [2]: No such file or directory (max_f
d=300) in C:\php\bug.php on line 26
bool(false)
HTTP/1.0 200 OK

-----

PHP version:
C:\php>php -v
PHP 5.6.12 (cli) (built: Aug  6 2015 12:05:19)

I uninstalled the Security Suite software to ensure it was not related to that.  Still have the same issue.

If this is an environment issue, what things should I be looking for?

I will also take a copy of this home and test it there.
 [2015-09-08 18:23 UTC] requinix@php.net
-Status: Closed +Status: Re-Opened
 [2015-09-09 04:08 UTC] mwilmes at wilminator dot com
Ran the latest bug script on my home computer.  I did not encounter the error.  The output:
C:\PHP56>php bug.php
resource(4) of type (stream)
HTTP/1.0 200 OK
<br>
resource(5) of type (stream)
int(1)
HTTP/1.0 200 OK

C:\PHP56>php -v
PHP 5.6.13 (cli) (built: Sep  3 2015 15:13:29)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies


Since this is 5.6.13 and not 5.6.12, I'm going to download a copy of 5.6.12 to see if I can recreate this issue.  If not, I am going to try to identify what is happening on my work system as I have seen a few similar errors and I'm wondering if they are antivirus related.
 [2015-09-09 04:14 UTC] mwilmes at avc dot edu
-Status: Re-Opened +Status: Closed
 [2015-09-09 04:14 UTC] mwilmes at avc dot edu
I just tried the test script with PHP 5.6.12 on my Win10 computer at home and it works fine.  I'm closing this ticket; it is the work environment.  I will do a little digging to see if I can identify what on the computer is causing PHP to not operate correctly.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Jul 17 12:01:28 2024 UTC