PHP Класс 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.
См. также: lithium\net\socket\Stream
Наследование: extends lithium\net\Socket
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
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

Описание методов

close() публичный Метод

Closes the stream
public close ( ) : boolean
Результат boolean True on closed connection

encoding() публичный Метод

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
Результат boolean Returns `false` if `stream_encoding()` function does not exist, boolean result of `stream_encoding()` otherwise.

eof() публичный Метод

Determines if the socket resource is at EOF.
public eof ( ) : boolean
Результат boolean Returns `true` if resource pointer is at its EOF, `false` otherwise.

open() публичный Метод

Opens a socket and initializes the internal resource handle.
public open ( array $options = [] ) : mixed
$options array update the config settings
Результат 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() публичный Метод

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.
Результат string Returns string read from stream resource on success, false otherwise.

timeout() публичный Метод

Set timeout period on a stream.
public timeout ( integer $time ) : boolean
$time integer The timeout value in seconds.
Результат boolean

write() публичный Метод

writes data to the stream resource
public write ( string $data = null ) : mixed
$data string The string to be written.
Результат mixed False on error, number of bytes written otherwise.