ID: 25828
Updated by: [EMAIL PROTECTED]
Reported By: scouture at novo dot ca
-Status: Open
+Status: Feedback
Bug Type: Performance problem
Operating System: win2000
PHP Version: 4.3.3
New Comment:
Does the returned data include a newline?
If not you should be using fread().
OR, you can use stream_select(),
OR you can use stream_set_timeout() to reduce the default
timeout from 60 seconds to something more appropriate to your
application.
Previous Comments:
------------------------------------------------------------------------
[2003-10-10 16:01:34] scouture at novo dot ca
Description:
------------
I was using php 4.2.2 before updating to 4.3.3.
I have to talk to another application server using socket.
With 4.2.2, i had my response in less than a second but it take me
about 60 sec with php 4.3.3
Reproduce code:
---------------
function getFromSocket($message){
set_time_limit (0);
$res = @fsockopen ("192.168.10.5", "3734", $errno, $errstr,30);
if(!$res) {
exit; //some eror...
}
else{
fputs($res, $message);
//samething, reponding server end the response by SCKEND
// while (substr_count($buff, "SCKEND")!= 1)
while ($bytes != "0"){
$buff .= fgets($res,4096);
//$array_statusSocket = socket_get_status($res); //for 4.2.2
$array_statusSocket = stream_get_meta_data($res);
$bytes = $array_statusSocket["unread_bytes"];
}
fclose ($res);
}
return $buff;
}
function getMicrotime(){
list($usec, $sec) = explode(" ",microtime());
return ((float)$usec + (float)$sec);
}
$time_requete = getMicrotime();
$str_resultatSocket =
getFromSocket("LOG|novojustice|justicenovo|intranet||SCKEND");
$time_requete2 = getMicrotime();
echo $time_requete2-$time_requete ." time<hr>";
exit;
Expected result:
----------------
have the result more quickly
Actual result:
--------------
took about 60sec..
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=25828&edit=1