RE: [PHP-DEV] Streams Problems
| From: | Mike Robinson | Date: | Sat, 12 Oct 2002 16:31:53 +0000 |
| Subject: | RE: [PHP-DEV] Streams Problems | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-89389@lists.php.net to get a copy of this message | ||
Im not sure if this is related, but using fopen or fsockopen
to retrieve a document that sends a redirect header (in this
case a 302 Moved Permanently trying to pull the slashdot
headlines rdf/xml file) fails. Worked fine in 4.2.3. This is
the case with 4.3.0pr1 and CVS for a little while now.
Regards
Mike Robinson
> -----Original Message-----
> From: Ilia A. [mailto:ilia@prohost.org]
> Sent: Friday, October 11, 2002 10:11 PM
> To: php-dev@lists.php.net; Wez Furlong
> Subject: [PHP-DEV] Streams Problems
>
>
> 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
>