There are 3 streams related problems I've come across today while using CVS
code. First it seems that sending of binary data in excess of 8k causes some
of the data not to be sent. This can be easily replicated with the following
test code:
<?php
$test_binary_file = file_get_contents("file_name");
$length = strlen($test_binary_file);
$fs = fsockopen("host", "port");
$written = fwrite($fs, $test_binary_file)
fclose($fs);
?>
According to fwrite() output all the data has been written, since $length
equals to $written. However, using a network monitoring tool, Ethereal I was
able to see that only about 8k worth of data was sent. This was confirmed by
another script that set on the receiving end.
Another problem I've come across is about reading from sockets that do no
terminate connection. Using the following script I've connected to a
webserver, in php 4.2.3 the script returns immediately after the last byte
has been read. In CVS the script wait about 10 seconds after all the data has
been read before finally terminating (timing out?). The example script is
below:
<?php
$fp = fsockopen("host", 80);
fwrite($fp, "GET / HTTP/1.1\r\nHost: host\r\n\r\n");
while ( ($data = fgets($fp, 1024)) ) {
echo $data;
}
flose($fp);
?>
The third problem is coredump that is fairly easily replicate with the script
below:
<?php
$fp = fsockopen("localhost", 80);
fputs($fp, "GET / HTTP/1.0\r\n\r\n");
fgets($fp, 1000000000);
?>
Ilia
--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php