PHP Class lithium\net\socket\Stream

This stream adapter provides the required method implementations of the abstract Socket class for the open(), close(), read(), write(), timeout() eof() and encoding() methods.
See also: lithium\net\socket\Stream
Inheritance: extends lithium\net\Socket
Show file Open project: unionofrad/lithium Class Usage Examples

Public Methods

Method Description
close ( ) : boolean Closes the stream
encoding ( string $charset ) : boolean Sets the character set for stream encoding if possible. The stream_encoding function is not guaranteed to be available as it is seems as if it's experimental or just not officially documented. If the function is not available returns false.
eof ( ) : boolean Determines if the socket resource is at EOF.
open ( array $options = [] ) : mixed Opens a socket and initializes the internal resource handle.
read ( integer $length = null, integer $offset = null ) : string Reads data from the stream resource
timeout ( integer $time ) : boolean Set timeout period on a stream.
write ( string $data = null ) : mixed writes data to the stream resource

Method Details

close() public method

Closes the stream
public close ( ) : boolean
return boolean True on closed connection

encoding() public method

Sets the character set for stream encoding if possible. The stream_encoding function is not guaranteed to be available as it is seems as if it's experimental or just not officially documented. If the function is not available returns false.
public encoding ( string $charset ) : boolean
$charset string
return boolean Returns `false` if `stream_encoding()` function does not exist, boolean result of `stream_encoding()` otherwise.

eof() public method

Determines if the socket resource is at EOF.
public eof ( ) : boolean
return boolean Returns `true` if resource pointer is at its EOF, `false` otherwise.

open() public method

Opens a socket and initializes the internal resource handle.
public open ( array $options = [] ) : mixed
$options array update the config settings
return mixed Returns `false` if the socket configuration does not contain the `'scheme'` or `'host'` settings, or if configuration fails, otherwise returns a resource stream. Throws exception if there is a network error.

read() public method

Reads data from the stream resource
public read ( integer $length = null, integer $offset = null ) : string
$length integer If specified, will read up to $length bytes from the stream. If no value is specified, all remaining bytes in the buffer will be read.
$offset integer Seek to the specified byte offset before reading.
return string Returns string read from stream resource on success, false otherwise.

timeout() public method

Set timeout period on a stream.
public timeout ( integer $time ) : boolean
$time integer The timeout value in seconds.
return boolean

write() public method

writes data to the stream resource
public write ( string $data = null ) : mixed
$data string The string to be written.
return mixed False on error, number of bytes written otherwise.