Class CakeSocket
Cake network socket connection class.
Core base class for network communication.
Direct Subclasses
Copyright: Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
License: License (http://www.opensource.org/licenses/mit-license.php)
Location: Cake/Network/CakeSocket.php
Properties summary
-
$_baseConfig
protectedarray
Base configuration settings for the socket connection -
$config
publicarray
Configuration settings for the socket connection -
$connected
publicboolean
This boolean contains the current state of the CakeSocket class -
$connection
publicresource
Reference to socket connection resource -
$description
publicstring
Object description -
$lastError
publicarray
This variable contains an array with the last error number (num) and string (str)
Method Summary
-
__construct() public
Constructor. -
__destruct() public
Destructor, used to disconnect from current connection. -
address() public
Get the IP address of the current connection. -
addresses() public
Get all IP addresses associated with the current connection. -
connect() public
Connect the socket to the given host and port. -
disconnect() public
Disconnect the socket from the current connection. -
host() public
Get the host name of the current connection. -
lastError() public
Get the last error as a string. -
read() public
Read data from the socket. Returns false if no data is available or no connection could be established.
-
reset() public
Resets the state of this Socket instance to it's initial state (before Object::__construct got executed) -
setLastError() public
Set the last error. -
write() public
Write data to the socket.
Method Detail
__construct() public ¶
__construct( array $config = array() )
Constructor.
Parameters
- array $config optional array()
- Socket configuration, which will be merged with the base configuration
See
address() public ¶
address( )
Get the IP address of the current connection.
Returns
IP address
addresses() public ¶
addresses( )
Get all IP addresses associated with the current connection.
Returns
IP addresses
disconnect() public ¶
disconnect( )
Disconnect the socket from the current connection.
Returns
Success
read() public ¶
read( integer $length = 1024 )
Read data from the socket. Returns false if no data is available or no connection could be established.
Parameters
- integer $length optional 1024
- Optional buffer length to read; defaults to 1024
Returns
Socket data
reset() public ¶
reset( array $state = null )
Resets the state of this Socket instance to it's initial state (before Object::__construct got executed)
Parameters
- array $state optional null
- Array with key and values to reset
Returns
True on success
setLastError() public ¶
setLastError( integer $errNum , string $errStr )
Set the last error.
Parameters
- integer $errNum
- Error code
- string $errStr
- Error string
Properties detail
$_baseConfig ¶
Base configuration settings for the socket connection
array( 'persistent' => false, 'host' => 'localhost', 'protocol' => 'tcp', 'port' => 80, 'timeout' => 30 )
$lastError ¶
This variable contains an array with the last error number (num) and string (str)
array()