Weird fsockopen behavior
| From: | Boaz Yahav | Date: | Fri, 22 Mar 2002 15:48:46 +0000 |
| Subject: | Weird fsockopen behavior | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-89698@lists.php.net to get a copy of this message | ||
Hi
I'm using
$fp=fsockopen($URL,80, &$errno, &$errstr,10);
set_socket_blocking($fp,false);
to get the HTML from a remote site and monitor how long it took me to DL
the HTML.
The next lines are like this :
if ($fp) {
$SendGetStart = getmicrotime();
fwrite($fp,"GET / HTTP/1.1\r\n");
fwrite($fp,"Accept: */*\r\n");
fwrite($fp,"Accept-Language: en-us\r\n");
fwrite($fp,"Proxy-Connection: Keep-Alive\r\n");
fwrite($fp,"User-Agent: Mozilla/4.0 (compatible; MSIE 5.5;
Windows NT 5.0; COM+ 1.0.2204)\r\n");
fwrite($fp,"Host:$Host\r\n\r\n");
..........
While(!feof($fp)) {...............
The weird thing is that it seems the EOF comes in great delay. When I
print the HTML I get from the remote site, the while loop continues for
about 10-15 seconds after the last </HTML> tag arrived. This is for any
site I check so it's not something specific to the web server I'm
testing.
Anyone has any idea why?
Thanks
berber