PHP Class lithium\net\Socket

Inheritance: extends lithium\core\Object
Datei anzeigen Open project: unionofrad/lithium Class Usage Examples

Protected Properties

Property Type Description
$_autoConfig array Auto config.
$_classes array The classes for the socket.
$_resource resource The resource for the current connection.

Public Methods

Method Description
__construct ( array $config = [] ) : void Constructor.
__destruct ( ) : void Destructor.
close ( ) : boolean Closes the socket and unsets Socket::$_resource.
encoding ( string $charset ) : boolean Sets the encoding of the socket connection.
eof ( ) : boolean Test for the end-of-file on the socket.
open ( array $options = [] ) : mixed Opens the socket and sets Socket::$_resource.
read ( ) : object Reads from the socket.
resource ( ) : resource Returns the resource.
send ( Message $message = null, array $options = [] ) : object Aggregates read and write methods into a coherent request response
set ( array $flags, array $value = null ) : void Sets the options to be used in subsequent requests.
timeout ( integer $time ) : boolean Sets the timeout on the socket *connection*.
write ( mixed $data ) : boolean Writes data to the socket.

Method Details

__construct() public method

Constructor.
public __construct ( array $config = [] ) : void
$config array Available configuration options are: - `'persistent'`: Use a persistent connection (defaults to `false`). - `'protocol'`: Transfer protocol to use (defaults to `'tcp'`). - `'host'`: Host name or address (defaults to `'localhost'`). - `'login'`: Username for a login (defaults to `'root'`). - `'password'`: Password for a login (defaults to `''`). - `'port'`: Host port (defaults to `80`). - `'timeout'`: Seconds after opening the socket times out (defaults to `30`).
return void

__destruct() public method

Destructor.
public __destruct ( ) : void
return void

close() abstract public method

Closes the socket and unsets Socket::$_resource.
abstract public close ( ) : boolean
return boolean `true` on success, `false` otherwise.

encoding() abstract public method

Sets the encoding of the socket connection.
abstract public encoding ( string $charset ) : boolean
$charset string The character set to use.
return boolean `true` if encoding has been set, `false` otherwise.

eof() abstract public method

Test for the end-of-file on the socket.
abstract public eof ( ) : boolean
return boolean `true` if end has been reached, `false` otherwise.

open() public method

Opens the socket and sets Socket::$_resource.
public open ( array $options = [] ) : mixed
$options array Update the config settings.
return mixed The open resource on success, `false` otherwise.

read() abstract public method

Reads from the socket.
abstract public read ( ) : object
return object `lithium\net\Message`

resource() public method

Returns the resource.
public resource ( ) : resource
return resource

send() public method

Aggregates read and write methods into a coherent request response
public send ( Message $message = null, array $options = [] ) : object
$message Message
$options array - '`response`': a fully-namespaced string for the response object
return object a response object based on `\lithium\net\Message`

set() public method

Sets the options to be used in subsequent requests.
public set ( array $flags, array $value = null ) : void
$flags array If $values is an array, $flags will be used as the keys to an associative array of curl options. If $values is not set, then $flags will be used as the associative array.
$value array If set, this array becomes the values for the associative array of curl options.
return void

timeout() abstract public method

Sets the timeout on the socket *connection*.
abstract public timeout ( integer $time ) : boolean
$time integer Seconds after the connection times out.
return boolean `true` if timeout has been set, `false` otherwise.

write() abstract public method

Writes data to the socket.
abstract public write ( mixed $data ) : boolean
$data mixed
return boolean `true` if data has been successfully written, `false` otherwise.

Property Details

$_autoConfig protected_oe property

Auto config.
protected array $_autoConfig
return array

$_classes protected_oe property

The classes for the socket.
protected array $_classes
return array

$_resource protected_oe property

The resource for the current connection.
protected resource $_resource
return resource