\SocketServerConnectionTransmitter.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\SocketServerConnectionTransmitter

Package: PEAR2\Net\Transmitter

A transmitter for connections to a socket server.

This is a convinience wrapper for functionality of socket server connections. Used to ensure data integrity. Server handling is not part of the class in order to allow its usage as part of various server implementations (e.g. fork and/or sequential).

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

Propertyprotectedstring  $peerIP= ''

The IP address of the connected client.
Details
Type
string
Propertyprotectedint  $peerPort= ''

The port of the connected client.
Details
Type
int
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( resource $server, float $timeout = null ) : void

Creates a new connection with the specified options.

Parameters
Name Type Description
$server resource

A socket server, created with {@link stream_socket_server()}.

$timeout float

The timeout for the connection.

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.
methodpublicgetPeerIP( ) : string

Gets the IP address of the connected client.

Returns
Type Description
string The IP address of the connected client.
methodpublicgetPeerPort( ) : int

Gets the port of the connected client.

Returns
Type Description
int The port of the connected client.
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.
methodpublicisServer( mixed $var ) : bool
static

Checks whether a cetain variable is a socket server.

Parameters
Name Type Description
$var mixed

The variable to check.

Returns
Type Description
bool TRUE on success, FALSE on failure.
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.