CakePHP network socket connection class.
Core base class for network communication.
__construct( array $config [] )
Constructor.
$config
optional [] _connectionErrorHandler( integer $code , string $message )
socket_stream_client() does not populate errNum, or $errStr when there are connection errors, as in the case of SSL verification failure.
Instead we need to handle those errors manually.
$code
$message
_setSslContext( string $host )
Configure the SSL context options.
$host
address( )
Get the IP address of the current connection.
string
addresses( )
Get all IP addresses associated with the current connection.
array
connect( )
Connect the socket to the given host and port.
boolean
Cake\Network\Exception\SocketException
context( )
Get the connection context.
null|array
disconnect( )
Disconnect the socket from the current connection.
boolean
enableCrypto( string $type , string $clientOrServer 'client' , boolean $enable true )
Encrypts current stream socket, using one of the defined encryption methods
$type
$clientOrServer
optional 'client' $enable
optional true boolean
InvalidArgumentException
Cake\Network\Exception\SocketException
read( integer $length 1024 )
Read data from the socket. Returns false if no data is available or no connection could be established.
$length
optional 1024 mixed
reset( array $state null )
Resets the state of this Socket instance to it's initial state (before Object::__construct got executed)
$state
optional null boolean
setLastError( integer $errNum , string $errStr )
Set the last error.
$errNum
$errStr
write( string $data )
Write data to the socket.
$data
boolean
_configDelete( string $key )
Delete a single config key
$key
Cake\Core\Exception\Exception
_configRead( string|null $key )
Read a config variable
$key
mixed
_configWrite( string|array $key , mixed $value , boolean|string $merge false )
Write a config variable
$key
$value
$merge
optional false Cake\Core\Exception\Exception
config( string|array|null $key null , mixed|null $value null , boolean $merge true )
Reading the whole config:
$this->config();
Reading a specific value:
$this->config('key');
Reading a nested value:
$this->config('some.nested.key');
Setting a specific value:
$this->config('key', $value);
Setting a nested value:
$this->config('some.nested.key', $value);
Updating multiple config settings at the same time:
$this->config(['one' => 'value', 'another' => 'value']);
$key
optional null $value
optional null $merge
optional true mixed
Cake\Core\Exception\Exception
configShallow( string|array $key , mixed|null $value null )
Merge provided config with existing config. Unlike config()
which does a recursive merge for nested keys, this method does a simple merge.
Setting a specific value:
$this->config('key', $value);
Setting a nested value:
$this->config('some.nested.key', $value);
Updating multiple config settings at the same time:
$this->config(['one' => 'value', 'another' => 'value']);
$key
$value
optional null mixed
protected boolean
Whether the config property has already been configured with defaults
false
© 2005–2016 The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
http://api.cakephp.org/3.1/class-Cake.Network.Socket.html