PHP Class Horde\Socket\Client

Author: Michael Slusarz ([email protected])
Author: Jan Schneider ([email protected])
Datei anzeigen Open project: horde/horde Class Usage Examples

Protected Properties

Property Type Description
$_connected boolean Is there an active connection?
$_params array Configuration parameters.
$_secure boolean Is the connection secure?
$_stream resource The actual socket.

Public Methods

Method Description
__clone ( ) This object can not be cloned.
__construct ( string $host, integer $port = null, integer $timeout = 30, mixed $secure = false, array $context = [], array $params = [] ) Constructor.
__get ( $name )
__sleep ( ) This object can not be serialized.
close ( ) Close the connection.
getStatus ( ) : array Returns information about the connection.
gets ( integer $size ) : string Returns a line of data.
read ( integer $size ) : string Returns a specified amount of data.
startTls ( ) : boolean Start a TLS connection.
write ( string $data ) Writes data to the stream.

Protected Methods

Method Description
_checkStream ( ) Throws an exception is the stream is not a resource.
_connect ( $host, $port, $timeout, $secure, $context, $retries ) Connect to the remote server.

Method Details

__clone() public method

This object can not be cloned.
public __clone ( )

__construct() public method

Constructor.
public __construct ( string $host, integer $port = null, integer $timeout = 30, mixed $secure = false, array $context = [], array $params = [] )
$host string Hostname of remote server (can contain protocol prefx).
$port integer Port number of remote server.
$timeout integer Connection timeout (in seconds).
$secure mixed Security layer requested. One of: - false: (No encryption) [DEFAULT] - 'ssl': (Auto-detect SSL version) - 'sslv2': (Force SSL version 3) - 'sslv3': (Force SSL version 2) - 'tls': (TLS; started via protocol-level negotation over unencrypted channel) - 'tlsv1': (TLS version 1.x connection) - true: (TLS if available/necessary)
$context array Any context parameters passed to stream_create_context().
$params array Additional options.

__get() public method

public __get ( $name )

__sleep() public method

This object can not be serialized.
public __sleep ( )

_checkStream() protected method

Throws an exception is the stream is not a resource.
protected _checkStream ( )

_connect() protected method

Connect to the remote server.
See also: __construct()
protected _connect ( $host, $port, $timeout, $secure, $context, $retries )

close() public method

Close the connection.
public close ( )

getStatus() public method

Currently returns four entries in the result array: - timed_out (bool): The socket timed out waiting for data - blocked (bool): The socket was blocked - eof (bool): Indicates EOF event - unread_bytes (int): Number of bytes left in the socket buffer
public getStatus ( ) : array
return array Information about existing socket resource.

gets() public method

Returns a line of data.
public gets ( integer $size ) : string
$size integer Reading ends when $size - 1 bytes have been read, or a newline or an EOF (whichever comes first).
return string $size bytes of data from the socket

read() public method

Returns a specified amount of data.
public read ( integer $size ) : string
$size integer The number of bytes to read from the socket.
return string $size bytes of data from the socket.

startTls() public method

Start a TLS connection.
public startTls ( ) : boolean
return boolean Whether TLS was successfully started.

write() public method

Writes data to the stream.
public write ( string $data )
$data string Data to write.

Property Details

$_connected protected_oe property

Is there an active connection?
protected bool $_connected
return boolean

$_params protected_oe property

Configuration parameters.
protected array $_params
return array

$_secure protected_oe property

Is the connection secure?
protected bool $_secure
return boolean

$_stream protected_oe property

The actual socket.
protected resource $_stream
return resource