note 45583 deleted from function.fsockopen by tomsommer
| From: | tomsommer@php.net | Date: | Sun, 12 Sep 2004 00:33:13 +0000 |
| Subject: | note 45583 deleted from function.fsockopen by tomsommer | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-76491@lists.php.net to get a copy of this message | ||
Note Submitter: mikebNOSPAM at xamo dot com
----
For those having timeout problems with feof(), it seems that socket_get_status() doesn't
completely work either.
The following code:
$fd=fsockopen("someurl.com",80,$errno,$errstr,10);
if($fd){
stream_set_timeout($fd,10);
fwrite($fd,"GET / HTTP/1.1\r\n"); // ok assume ive sent a valid request
$contents=fread($fd,128);
$bytes_left=socket_get_status($fd);
do{
$contents.=fread($fd,$bytes_left["unread_bytes"]);
$bytes_left=socket_get_status($fd);
}while($bytes_left["unread_bytes"]);
}else{
echo "Could not connect.";
}
this doesnt completely work. I'm finding I only get about half of the data sent by the
connected web server. Seems the unread_bytes is getting set to 0 early. Can't figure out why!