function Net_Socket::write in Flickr API 5
Write a specified amount of data.
@access public
Parameters
string $data Data to write.:
integer $blocksize Amount of data to write at once.: NULL means all at once.
Return value
mixed true on success or an error object otherwise
File
- phpFlickr/
PEAR/ Net/ Socket.php, line 286
Class
- Net_Socket
- Generalized Socket class.
Code
function write($data, $blocksize = null) {
if (!is_resource($this->fp)) {
return $this
->raiseError('not connected');
}
if (is_null($blocksize) && !OS_WINDOWS) {
return fwrite($this->fp, $data);
}
else {
if (is_null($blocksize)) {
$blocksize = 1024;
}
$pos = 0;
$size = strlen($data);
while ($pos < $size) {
$written = @fwrite($this->fp, substr($data, $pos, $blocksize));
if ($written === false) {
return false;
}
$pos += $written;
}
return $pos;
}
}