\SocketClientTransmitter.php

Show: inherited

Wrapper for stream functionality.

This package provides data integrity to stream functionality, particularly useful for sockets.

PHP version 5

Author
Vasil Rangelov  
Category
Net  
Copyright
2011 Vasil Rangelov  
License
LGPL License 2.1  
Link
http://netrouteros.sourceforge.net/  
Package
PEAR2_Net_Transmitter  
Version
1.0.0a1  

\PEAR2\Net\Transmitter\SocketClientTransmitter

Package: PEAR2\Net\Transmitter

A socket transmitter.

This is a convinience wrapper for socket functionality. Used to ensure data integrity.

Parent(s)
\PEAR2\Net\Transmitter\StreamTransmitter
See
\PEAR2\Net\Transmitter\Client  
Author
Vasil Rangelov  
Category
Net  
License
LGPL License 2.1  
Link
http://netrouteros.sourceforge.net/  

Properties

Propertyprotectedint  $error_no= 'null'

The error code of the last error on the socket.
Default valuenullDetails
Type
int
Propertyprotectedstring  $error_str= 'null'

The error message of the last error on the socket.
Default valuenullDetails
Type
string
Propertyprotectedbool  $persist= ''
inherited

A flag that tells whether or not the stream is persistent.Inherited from: \PEAR2\Net\Transmitter\StreamTransmitter::$persist
Details
Type
bool
Inherited_from
\PEAR2\Net\Transmitter\StreamTransmitter::$persist  
Propertyprotectedresource  $stream= ''
inherited

The stream to wrap around.Inherited from: \PEAR2\Net\Transmitter\StreamTransmitter::$stream
Details
Type
resource
Inherited_from
\PEAR2\Net\Transmitter\StreamTransmitter::$stream  

Methods

methodpublic__construct( string $host, int $port = 8728, bool $persist = false, float $timeout = null, string $key = '', resource $context = null ) : void

Creates a new connection with the specified options.

Parameters
Name Type Description
$host string

Hostname (IP or domain) of the server.

$port int

The port on the server.

$persist bool

Whether or not the connection should be a persistent one.

$timeout float

The timeout for the connection.

$key string

A string that uniquely identifies the connection.

$context resource

A context for the socket.

methodpublic__destruct( ) : void
inherited

Closes the opened stream, unless it's a persistent one.

Inherited from: \PEAR2\Net\Transmitter\StreamTransmitter::__destruct()
methodpublicclose( ) : bool
inherited

Closes the opened stream, even if it is a persistent one.

Inherited from: \PEAR2\Net\Transmitter\StreamTransmitter::close()
Returns
Type Description
bool TRUE on success, FALSE on failure.
methodprotectedcreateException( string $message, int $code = 0 ) : \PEAR2\Net\Transmitter\SocketException

Creates a new exception.

Creates a new exception. Used by the rest of the functions in this class.

Parameters
Name Type Description
$message string

The exception message.

$code int

The exception code.

Returns
Type Description
\PEAR2\Net\Transmitter\SocketException The exception to then be thrown.
methodpublicisAcceptingData( ) : bool
inherited

Checks whether the wrapped stream can be written to without a block.

Inherited from: \PEAR2\Net\Transmitter\StreamTransmitter::isAcceptingData()
Returns
Type Description
bool TRUE if the wrapped stream would not block on a write, FALSE otherwise.
methodpublicisAvailable( ) : bool
inherited

Checks whether the stream is available for operations.

Inherited from: \PEAR2\Net\Transmitter\StreamTransmitter::isAvailable()
Returns
Type Description
bool TRUE if the stream is available, FALSE otherwise.
methodpublicisDataAwaiting( ) : bool

Checks whether there is data to be read from the socket.

Returns
Type Description
bool TRUE if there is data to be read, FALSE otherwise.
methodpublicisFresh( ) : bool
inherited

Checks whether the wrapped stream is fresh.

Inherited from: \PEAR2\Net\Transmitter\StreamTransmitter::isFresh()

Checks whether the wrapped stream is fresh. A stream is considered fresh if there hasn't been any activity on it. Particularly useful for detecting reused persistent connections.

Returns
Type Description
bool TRUE if the socket is fresh, FALSE otherwise.
methodpublicisStream( mixed $var ) : bool
staticinherited

Checks if a given variable is a stream resource.

Inherited from: \PEAR2\Net\Transmitter\StreamTransmitter::isStream()
Parameters
Name Type Description
$var mixed

The variable to check.

Returns
Type Description
bool TRUE on success, FALSE on failure.
methodpublicreceive( int $length, string $what = 'data' ) : string
inherited

Reads from the wrapped stream to receive.

Inherited from: \PEAR2\Net\Transmitter\StreamTransmitter::receive()

Reads from the wrapped stream to receive content as a string.

Parameters
Name Type Description
$length int

The number of bytes to read.

$what string

Descriptive string about what is being received (used in exception messages).

Returns
Type Description
string The received content.
methodpublicreceiveStream( int $length, array $filters = array(, string $what = 'stream data' ) : resource
inherited

Reads from the wrapped stream to receive.

Inherited from: \PEAR2\Net\Transmitter\StreamTransmitter::receiveStream()

Reads from the wrapped stream to receive content as a stream.

Parameters
Name Type Description
$length int

The number of bytes to read.

$filters array

An array of filters to apply to the stream while receiving. Key is the filter name, value is an array of parameters for the filter.

$what string

Descriptive string about what is being received (used in exception messages).

Returns
Type Description
resource The received content.
methodpublicsend( string $string ) : int
inherited

Sends a string over the wrapped stream.

Inherited from: \PEAR2\Net\Transmitter\StreamTransmitter::send()
Parameters
Name Type Description
$string string

The string to send.

Returns
Type Description
int The number of bytes sent.
methodpublicsendStream( resource $stream ) : int
inherited

Sends a stream over the wrapped stream.

Inherited from: \PEAR2\Net\Transmitter\StreamTransmitter::sendStream()
Parameters
Name Type Description
$stream resource

The stream to send.

Returns
Type Description
int The number of bytes sent.
methodpublicsetBuffer( int $size, string $direction = self::DIRECTION_BOTH ) : bool
inherited

Sets the size of a stream's buffer.

Inherited from: \PEAR2\Net\Transmitter\StreamTransmitter::setBuffer()
Parameters
Name Type Description
$size int

The desired size of the buffer, in bytes.

$direction string

The buffer of which direction to set. Valid values are the DIRECTION_* constants.

Returns
Type Description
bool TRUE on success, FALSE on failure.
methodpublicsetTimeout( int $seconds, int $microseconds = 0 ) : bool
inherited

Sets the timeout for the stream.

Inherited from: \PEAR2\Net\Transmitter\StreamTransmitter::setTimeout()
Parameters
Name Type Description
$seconds int

Timeout in seconds.

$microseconds int

Timeout in microseconds to be added to the seconds.

Returns
Type Description
bool TRUE on success, FALSE on failure.
Documentation was generated by DocBlox 0.14.1.