Ferreteria/v0.6/clade/IO/Aspect/Connx/Process/@fx/StreamToPipe
Jump to navigation
Jump to search
|
fx:
StreamToPipe() |
About
- Action: Write from the given stream to the given pipe resource.
Code
#
protected function StreamToPipe(BufferIface $oData, $rPipe) {
// Process the stream in a loop
$oData->Open();
while ($oData->IsMore()) {
// Time-out if I/O hangs for more than 5 seconds:
#$ok = set_time_limit(5); // NOTE: seems to always return FALSE
$sPiece = $oData->RemoveBytes();
// WORKING HERE
$ok = fwrite($rPipe,$sPiece); // TODO: this should check $ok to make sure it wrote the entire buffer -- remaining part needs to be sent again
if ($ok === FALSE) {
$this->AmHere('TODO: handle write error');
} elseif($ok !== strlen($sPiece)) {
$nlDone = $ok;
$nlPiece = strlen($sPiece);
#$this->AmHere("TODO: handle incomplete write (sent: $nlPiece actual: $ok)");
$sRem = substr($sPiece,$nlDone);
$oSendBuff->RestoreBytes($sRem);
} else {
$this->AmHere('TODO: handle whatever is supposed to happen here.');
}
}
$oData->Shut();
}