ID:               33568
 Updated by:       [EMAIL PROTECTED]
 Reported By:      shaun at verticalevolution dot com
 Status:           Feedback
 Bug Type:         Sockets related
 Operating System: Windows XP SP2
 PHP Version:      5.0.4
 New Comment:

Please also remove the stream_set_timeout() call from your script(s)
and note that you are not using stream_select() correctly (the
read/write/excep arrays need to be set on *each* call).


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

[2005-07-04 21:58:30] [EMAIL PROTECTED]

Please try using this CVS snapshot:

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



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

[2005-07-04 21:04:51] shaun at verticalevolution dot com

Description:
------------
Once the FEOF flag has been triggered on a stream you are unable to
then write to that stream.

I created a stream_socket_server, accepted a client
(stream_socket_accept) then attempted to read all the contents from the
stream (while!feof()) I am not able to then write to that same client
stream. 

It appears that once the feof flag has been it the stream is no longer
able to be written to.

Reproduce code:
---------------
SERVER:

<?php

 $sock = stream_socket_server('tcp://127.0.0.1:1899', $errno,
$errstr);
 
 $read = Array($sock);
 $i = '';
 
 while(1){
  $ready = stream_select($read, $write = NULL, $except = NULL, 10);
  
  $c = stream_socket_accept($sock);
  var_dump(stream_get_meta_data($c));
  
  while(!feof($c)){
   $i .= fread($c, 12);
  }
  echo $i;
  
  fwrite($c, 'testback');
  break;
 }
 
 fclose($sock);

?>

CLIENT:

<?php
  $output = '';
  
  $sock = stream_socket_client('tcp://127.0.0.1:1899',$errcode,
$errstr);
  fwrite($sock, 'test');
 stream_set_timeout($sock, 5);
 while(!feof($sock)){
  $output = fread($sock, 1024);
 }
 fclose($sock);
  
 echo $output;
?>

Expected result:
----------------
On the server I should see "test" printed out then on the client I
should see "testback" printed out.



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


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

Reply via email to