note 45583 added to function.fsockopen

From: Date: Sat, 11 Sep 2004 23:19:33 +0000
Subject: note 45583 added to function.fsockopen
Groups: php.notes 
Request: Send a blank email to php-notes+get-76487@lists.php.net to get a copy of this message
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! ---- Manual Page -- http://www.php.net/manual/en/function.fsockopen.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+45583 Delete -- http://master.php.net/manage/user-notes.php?action=delete+45583&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+45583&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#76487) next »