A generic IoBuffer implementation supporting remote sockets and local processes.

package Swift
subpackage Transport
author Chris Corbyn

 Methods

Create a new StreamBuffer using $replacementFactory for transformations.

__construct(\Swift_ReplacementFilterFactory $replacementFactory) 

Parameters

$replacementFactory

\Swift_ReplacementFilterFactory

Add a StreamFilter to this InputByteStream.

addFilter(\Swift_StreamFilter $filter, string $key) 
Inherited
inherited_from \Swift_ByteStream_AbstractFilterableInputStream::addFilter()

Parameters

$key

string

Attach $is to this stream.

bind(\Swift_InputByteStream $is) 
Inherited

The stream acts as an observer, receiving all data that is written. All write() and flushBuffers() operations will be mirrored.

inherited_from \Swift_InputByteStream::bind()
inherited_from \Swift_Transport_IoBuffer::bind()

Parameters

For any bytes that are currently buffered inside the stream, force them off the buffer.

commit() 
Inherited
inherited_from \Swift_InputByteStream::commit()
inherited_from \Swift_Transport_IoBuffer::commit()

Exceptions

\Swift_IoException

Flush the contents of the stream (empty it) and set the internal pointer to the beginning.

flushBuffers() 
Inherited
inherited_from \Swift_InputByteStream::flushBuffers()
inherited_from \Swift_Transport_IoBuffer::flushBuffers()

Exceptions

\Swift_IoException

Perform any initialization needed, using the given $params.

initialize(array $params) 

Parameters will vary depending upon the type of IoBuffer used.

Parameters

$params

array

Reads $length bytes from the stream into a string and moves the pointer through the stream by $length.

read(int $length) : string

If less bytes exist than are requested the remaining bytes are given instead. If no bytes are remaining at all, boolean false is returned.

Parameters

$length

int

Returns

string

Get a line of output (including any CRLF).

readLine(int $sequence) : string

The $sequence number comes from any writes and may or may not be used depending upon the implementation.

Parameters

$sequence

int

of last write to scan from

Returns

string

Remove an already present StreamFilter based on its $key.

removeFilter(string $key) 
Inherited
inherited_from \Swift_ByteStream_AbstractFilterableInputStream::removeFilter()

Parameters

$key

string

Set an individual param on the buffer (e.g.

setParam(string $param, mixed $value) 

switching to SSL).

Parameters

$param

string

$value

mixed

Not implemented

setReadPointer($byteOffset) 

Parameters

$byteOffset

Set an array of string replacements which should be made on data written to the buffer.

setWriteTranslations(array $replacements) 

This could replace LF with CRLF for example.

Parameters

$replacements

string[]

startTLS()

startTLS() 

Perform any shutdown logic needed.

terminate() 

Remove an already bound stream.

unbind(\Swift_InputByteStream $is) 
Inherited

If $is is not bound, no errors will be raised. If the stream currently has any buffered data it will be written to $is before unbinding occurs.

inherited_from \Swift_InputByteStream::unbind()
inherited_from \Swift_Transport_IoBuffer::unbind()

Parameters

Writes $bytes to the end of the stream.

write(string $bytes) : int
Inherited

Writing may not happen immediately if the stream chooses to buffer. If you want to write these bytes with immediate effect, call commit() after calling write().

This method returns the sequence ID of the write (i.e. 1 for first, 2 for second, etc etc).

inherited_from \Swift_InputByteStream::write()
inherited_from \Swift_Transport_IoBuffer::write()

Parameters

$bytes

string

Exceptions

\Swift_IoException

Returns

int

Write this bytes to the stream

_commit(string $bytes) 

Parameters

$bytes

string

Flush the stream contents

_flush() 

Just write the bytes to the stream

_doWrite($bytes) 
Inherited
inherited_from \Swift_ByteStream_AbstractFilterableInputStream::_doWrite()

Parameters

$bytes

Opens a process for input/output.

_establishProcessConnection() 
access private

Establishes a connection to a remote server.

_establishSocketConnection() 
access private

Run $bytes through all filters

_filter($bytes) 
Inherited
inherited_from \Swift_ByteStream_AbstractFilterableInputStream::_filter()

Parameters

$bytes

_getReadConnectionDescription()

_getReadConnectionDescription() 

 Properties

 

$_sequence 
Inherited
inherited_from \Swift_ByteStream_AbstractFilterableInputStream::$$_sequence
 

$_filters 
Inherited
inherited_from \Swift_ByteStream_AbstractFilterableInputStream::$$_filters
 

$_in 
 

$_mirrors 
Inherited
inherited_from \Swift_ByteStream_AbstractFilterableInputStream::$$_mirrors
 

$_out 
 

$_params 
 

$_replacementFactory 
 

$_stream 
 

$_translations 
 

$_writeBuffer 
Inherited
inherited_from \Swift_ByteStream_AbstractFilterableInputStream::$$_writeBuffer

 Constants

 

A process buffer with I/O support

TYPE_PROCESS 
Inherited
inherited_from \Swift_Transport_IoBuffer::TYPE_PROCESS
 

A socket buffer over TCP

TYPE_SOCKET 
Inherited
inherited_from \Swift_Transport_IoBuffer::TYPE_SOCKET