PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Networking » Net_Socket » Bug #6789

Net_Sock::eof() returns false when socket is already disconnected

Details

Submitted2006-02-15 10:21 UTC
Fromsatanistlav at mail dot ru
Assignedcweiske
StatusClosed
PackageNet_Socket
PHP Version5.0.5
OSWin XP
Roadmaps(Not assigned)

Comments

[2006-02-15 10:21 UTC] satanistlav at mail dot ru

Description:
------------
Net_Sock::eof() returns false when socket is already disconnected in HTTP_Request class line 1040

Test script:
---------------
class myListener extends HTTP_Request_Listener{
function update(&$subject, $event, $data = null){
if ($event == 'gotHeaders'){
$subject->_sock->disconnect();
//should disconnect after recieving headers but it wil l not
}elseif($event == 'gotBody'){
echo $data;
}
}
}

$request = new HTTP_Request('http://www.php.net/');
$request->attach(new myListener());
$request->sendRequest();

Expected result:
----------------
It should stop and should not download the the page body

Actual result:
--------------
FATAL: erealloc(): Unable to allocate nnnnnn bytes.

[2006-02-15 10:30 UTC] satanistlav at mail dot ru

it works fine when I change the code as below
function eof()
{
if (!is_resource($this->fp)) {
return true;
}
return feof($this->fp);
}