ID: 25828 User updated by: scouture at novo dot ca Reported By: scouture at novo dot ca -Status: Feedback +Status: Closed Bug Type: Performance problem Operating System: win2000 PHP Version: 4.3.3 New Comment:
I've changed my function using stream_select and fread instead and it works fine. So was more a coding problem than a bug finaly. Sorry for your time and thanks for your help Previous Comments: ------------------------------------------------------------------------ [2003-10-10 17:09:26] [EMAIL PROTECTED] Also, you really should not use stream_get_meta_data() and the unread_bytes value to drive your scripts. ------------------------------------------------------------------------ [2003-10-10 17:02:52] [EMAIL PROTECTED] 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. ------------------------------------------------------------------------ [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