CakePHP network socket connection class.
Core base class for network communication.
$_baseConfig protected array$_connectionErrors protected arrayUsed to capture connection warnings which can happen when there are SSL errors for example.
$_encryptMethods protected array$config public array$connected public boolean$connection public resource$description public string$encrypted public boolean$lastError public arraysocket_stream_client() does not populate errNum, or $errStr when there are connection errors, as in the case of SSL verification failure.
Reads data from the socket. Returns false if no data is available or no connection could be established.
__construct( array $config array() )
Constructor.
$config optional array() _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( )
Gets the IP address of the current connection.
addresses( )
Gets all IP addresses associated with the current connection.
connect( )
Connects the socket to the given host and port.
SocketExceptioncontext( )
Gets the connection context.
disconnect( )
Disconnects the socket from the current connection.
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 SocketExceptionlastError( )
Gets the last error as a string.
read( integer $length 1024 )
Reads data from the socket. Returns false if no data is available or no connection could be established.
$length optional 1024 reset( array $state null )
Resets the state of this Socket instance to it's initial state (before Object::__construct got executed)
$state optional null setLastError( integer $errNum , string $errStr )
Sets the last error.
$errNum $errStr write( string $data )
Writes data to the socket.
$data protected array
Base configuration settings for the socket connection
array(
'persistent' => false,
'host' => 'localhost',
'protocol' => 'tcp',
'port' => 80,
'timeout' => 30
) protected array
Used to capture connection warnings which can happen when there are SSL errors for example.
array()
protected array
Contains all the encryption methods available
array(
// @codingStandardsIgnoreStart
'sslv2_client' => STREAM_CRYPTO_METHOD_SSLv2_CLIENT,
'sslv3_client' => STREAM_CRYPTO_METHOD_SSLv3_CLIENT,
'sslv23_client' => STREAM_CRYPTO_METHOD_SSLv23_CLIENT,
'tls_client' => STREAM_CRYPTO_METHOD_TLS_CLIENT,
'sslv2_server' => STREAM_CRYPTO_METHOD_SSLv2_SERVER,
'sslv3_server' => STREAM_CRYPTO_METHOD_SSLv3_SERVER,
'sslv23_server' => STREAM_CRYPTO_METHOD_SSLv23_SERVER,
'tls_server' => STREAM_CRYPTO_METHOD_TLS_SERVER
// @codingStandardsIgnoreEnd
) public boolean
This boolean contains the current state of the CakeSocket class
false
public boolean
True if the socket stream is encrypted after a CakeSocket::enableCrypto() call
false
public array
This variable contains an array with the last error number (num) and string (str)
array()
© 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/2.8/class-CakeSocket.html